mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-25 11:52:40 +01:00
Fix panic
This commit is contained in:
parent
7f249ecf89
commit
22205aaa28
@ -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 <>
|
||||
|
Loading…
Reference in New Issue
Block a user