Skip to content

Commit c4ed2df

Browse files
committed
fix ScopeVar
1 parent 952e16f commit c4ed2df

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

game/game/gamescript.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ struct ScopeVar final {
3131
sym.set_instance(prev);
3232
}
3333

34-
const std::shared_ptr<phoenix::instance>& prev;
35-
phoenix::symbol& sym;
34+
std::shared_ptr<phoenix::instance> prev;
35+
phoenix::symbol& sym;
3636
};
3737

3838

@@ -427,7 +427,7 @@ void GameScript::loadDialogOU() {
427427
void GameScript::initializeInstanceNpc(const std::shared_ptr<phoenix::c_npc>& npc, size_t instance) {
428428
auto sym = vm.find_symbol_by_index(uint32_t(instance));
429429

430-
if (sym == nullptr) {
430+
if(sym == nullptr) {
431431
Tempest::Log::e("Cannot initialize NPC ", instance, ": Symbol not found.");
432432
return;
433433
}
@@ -438,17 +438,16 @@ void GameScript::initializeInstanceNpc(const std::shared_ptr<phoenix::c_npc>& np
438438
ScopeVar self(*vm.global_self(), npc);
439439
auto* daily_routine = vm.find_symbol_by_index(uint32_t(npc->daily_routine));
440440

441-
if (daily_routine != nullptr) {
441+
if(daily_routine != nullptr) {
442442
vm.call_function(daily_routine);
443443
}
444444
}
445-
446445
}
447446

448447
void GameScript::initializeInstanceItem(const std::shared_ptr<phoenix::c_item>& item, size_t instance) {
449448
auto sym = vm.find_symbol_by_index(uint32_t(instance));
450449

451-
if (sym == nullptr) {
450+
if(sym == nullptr) {
452451
Tempest::Log::e("Cannot initialize item ", instance, ": Symbol not found.");
453452
return;
454453
}
@@ -837,7 +836,7 @@ std::vector<GameScript::DlgChoise> GameScript::updateDialog(const GameScript::Dl
837836
return ret;
838837
}
839838

840-
void GameScript::exec(const GameScript::DlgChoise &dlg,Npc& player, Npc& npc) {
839+
void GameScript::exec(const GameScript::DlgChoise &dlg, Npc& player, Npc& npc) {
841840
ScopeVar self (*vm.global_self(), npc.handlePtr());
842841
ScopeVar other(*vm.global_other(), player.handlePtr());
843842

@@ -965,11 +964,13 @@ int GameScript::invokeState(Npc* npc, Npc* oth, Npc* vic, ScriptFn fn) {
965964

966965
auto* sym = vm.find_symbol_by_index(uint32_t(fn.ptr));
967966
int ret = 0;
968-
if (sym!=nullptr && sym->rtype() == phoenix::datatype::integer) {
967+
if(sym!=nullptr && sym->rtype() == phoenix::datatype::integer) {
969968
ret = vm.call_function<int>(sym);
970-
} else if (sym!=nullptr) {
969+
}
970+
else if(sym!=nullptr) {
971971
vm.call_function<void>(sym);
972-
}
972+
}
973+
973974
if(vm.global_other()->is_instance_of<phoenix::c_npc>()){
974975
auto oth2 = reinterpret_cast<phoenix::c_npc*>(vm.global_other()->get_instance().get());
975976
if(oth!=nullptr && oth2!=&oth->handle()) {

0 commit comments

Comments
 (0)