1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-10-06 09:07:19 +02:00

Merge pull request #516 from husho/fixpanic

Fix panic on new game
This commit is contained in:
Jannik Vogel 2018-06-18 23:58:03 +02:00 committed by GitHub
commit a9e76da678
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -224,10 +224,13 @@ ScriptObjectType<Payphone> ScriptArguments::getScriptObject(
unsigned int arg) const {
auto& param = (*this)[arg];
RW_CHECK(param.isLvalue(), "Non lvalue passed as object");
auto index = *param.handleValue();
RW_CHECK(index >= 0, "Object index is negative");
RW_CHECK(*param.handleValue() >= 0, "Object index is negative");
auto index = size_t(*param.handleValue());
auto& payphones = getWorld()->payphones;
auto payphone = payphones.at(size_t(index)).get();
Payphone* payphone = nullptr;
if (index < payphones.size()) {
payphone = payphones[index].get();
}
return {param.handleValue(), payphone};
}
template <>