mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-07 03:12:36 +01:00
Fix paramedic & vigilante submissions (#491)
Opcodes 0376 opcode "create_random_actor" was unimplemented and did return garbage to the script, and dereferencing nonexistent actor caused crashes
This commit is contained in:
parent
595b671f6d
commit
7f249ecf89
@ -5431,13 +5431,12 @@ void opcode_01e8(const ScriptArguments& args, ScriptVec3 coord0, ScriptVec3 coor
|
|||||||
|
|
||||||
opcode 01e9
|
opcode 01e9
|
||||||
@arg vehicle Car/vehicle
|
@arg vehicle Car/vehicle
|
||||||
@arg arg2
|
@arg numOfPassengers
|
||||||
*/
|
*/
|
||||||
void opcode_01e9(const ScriptArguments& args, const ScriptVehicle vehicle, ScriptInt& arg2) {
|
void opcode_01e9(const ScriptArguments& args, const ScriptVehicle vehicle,
|
||||||
RW_UNIMPLEMENTED_OPCODE(0x01e9);
|
ScriptInt& numOfPassengers) {
|
||||||
RW_UNUSED(vehicle);
|
|
||||||
RW_UNUSED(arg2);
|
|
||||||
RW_UNUSED(args);
|
RW_UNUSED(args);
|
||||||
|
numOfPassengers = vehicle->seatOccupants.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -5445,13 +5444,12 @@ void opcode_01e9(const ScriptArguments& args, const ScriptVehicle vehicle, Scrip
|
|||||||
|
|
||||||
opcode 01ea
|
opcode 01ea
|
||||||
@arg vehicle Car/vehicle
|
@arg vehicle Car/vehicle
|
||||||
@arg arg2
|
@arg maxNumOfPassengers
|
||||||
*/
|
*/
|
||||||
void opcode_01ea(const ScriptArguments& args, const ScriptVehicle vehicle, ScriptInt& arg2) {
|
void opcode_01ea(const ScriptArguments& args, const ScriptVehicle vehicle,
|
||||||
RW_UNIMPLEMENTED_OPCODE(0x01ea);
|
ScriptInt& maxNumOfPassengers) {
|
||||||
RW_UNUSED(vehicle);
|
|
||||||
RW_UNUSED(arg2);
|
|
||||||
RW_UNUSED(args);
|
RW_UNUSED(args);
|
||||||
|
maxNumOfPassengers = vehicle->info->seats.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -9939,11 +9937,22 @@ void opcode_0375(const ScriptArguments& args, const ScriptString gxtEntry0, cons
|
|||||||
@arg coord Coordinates
|
@arg coord Coordinates
|
||||||
@arg character Character/ped
|
@arg character Character/ped
|
||||||
*/
|
*/
|
||||||
void opcode_0376(const ScriptArguments& args, ScriptVec3 coord, ScriptCharacter& character) {
|
void opcode_0376(const ScriptArguments& args, ScriptVec3 coord,
|
||||||
RW_UNIMPLEMENTED_OPCODE(0x0376);
|
ScriptCharacter& character) {
|
||||||
RW_UNUSED(coord);
|
coord = script::getGround(args, coord);
|
||||||
RW_UNUSED(character);
|
auto world = args.getWorld();
|
||||||
RW_UNUSED(args);
|
auto state = args.getState();
|
||||||
|
auto data = world->data;
|
||||||
|
auto zone = data->findZoneAt(
|
||||||
|
world->getPlayer()->getCharacter()->getPosition());
|
||||||
|
const bool day =
|
||||||
|
(state->basic.gameHour >= 8 && state->basic.gameHour <= 19);
|
||||||
|
const int groupId =
|
||||||
|
zone ? (day ? zone->pedGroupDay : zone->pedGroupNight) : 0;
|
||||||
|
const auto& pedGroup = data->pedgroups.at(groupId);
|
||||||
|
const auto model = pedGroup.at(
|
||||||
|
args.getVM()->getRandomNumber((std::size_t)0, pedGroup.size() - 1));
|
||||||
|
character = world->createPedestrian(model, coord + script::kSpawnOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11097,11 +11106,9 @@ void opcode_03c5(const ScriptArguments& args, ScriptVec3 coord, const ScriptFloa
|
|||||||
bool opcode_03c6(const ScriptArguments& args, const ScriptLevel island) {
|
bool opcode_03c6(const ScriptArguments& args, const ScriptLevel island) {
|
||||||
// The parameter to this is actually the island number.
|
// The parameter to this is actually the island number.
|
||||||
// Not sure how that will fit into the scheme of full paging
|
// Not sure how that will fit into the scheme of full paging
|
||||||
/// @todo use the current player zone island number to return the correct value.
|
|
||||||
// this might be very slow
|
|
||||||
auto world = args.getWorld();
|
auto world = args.getWorld();
|
||||||
auto plyChar = world->pedestrianPool.find(world->state->playerObject);
|
auto zone = world->data->findZoneAt(
|
||||||
auto zone = world->data->findZoneAt(plyChar->getPosition());
|
world->getPlayer()->getCharacter()->getPosition());
|
||||||
|
|
||||||
return island == zone->island;
|
return island == zone->island;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user