diff options
author | Fedja Beader <fedja@protonmail.ch> | 2024-04-12 19:03:32 +0200 |
---|---|---|
committer | Fedja Beader <fedja@protonmail.ch> | 2024-04-22 18:56:31 +0200 |
commit | 000cdca878911759643e18a9648c587e9730fa91 (patch) | |
tree | 8635635134cfd49fed133e25168eeeac5c853f02 | |
parent | c6f6862303b28323f039a0b3bb17a189ce136658 (diff) | |
download | tmwa-000cdca878911759643e18a9648c587e9730fa91.tar.gz tmwa-000cdca878911759643e18a9648c587e9730fa91.tar.bz2 tmwa-000cdca878911759643e18a9648c587e9730fa91.tar.xz tmwa-000cdca878911759643e18a9648c587e9730fa91.zip |
Fix warning: 'T& tmwa::Slice<T>::operator[](size_t) is deprecated
-rw-r--r-- | src/char/char.cpp | 14 | ||||
-rw-r--r-- | src/map/script-call.cpp | 8 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/char/char.cpp b/src/char/char.cpp index a7f1490..7ffdd0f 100644 --- a/src/char/char.cpp +++ b/src/char/char.cpp @@ -1040,11 +1040,15 @@ int set_account_reg2(AccountId acc, Slice<GlobalReg> reg) { if (cd.key.account_id == acc) { - for (int i = 0; i < num; ++i) - cd.data->account_reg2[i] = reg[i]; - cd.data->account_reg2_num = num; - for (int i = num; i < ACCOUNT_REG2_NUM; ++i) - cd.data->account_reg2[i] = GlobalReg{}; + int i = 0; + for (const GlobalReg& r : reg) + cd.data->account_reg2[i++] = r; + + cd.data->account_reg2_num = i; + + while (i < ACCOUNT_REG2_NUM) + cd.data->account_reg2[i++] = GlobalReg{}; + c++; } } diff --git a/src/map/script-call.cpp b/src/map/script-call.cpp index 76bae8d..f551ec4 100644 --- a/src/map/script-call.cpp +++ b/src/map/script-call.cpp @@ -1004,12 +1004,12 @@ int run_script_l(ScriptPointer sp, BlockId rid, BlockId oid, st.freeloop = 0; st.is_true = 0; - for (i = 0; i < args.size(); i++) + for (const argrec_t& arg : args) { - if (args[i].name.back() == '$') - pc_setregstr(sd, SIR::from(variable_names.intern(args[i].name)), args[i].v.s); + if (arg.name.back() == '$') + pc_setregstr(sd, SIR::from(variable_names.intern(arg.name)), arg.v.s); else - pc_setreg(sd, SIR::from(variable_names.intern(args[i].name)), args[i].v.i); + pc_setreg(sd, SIR::from(variable_names.intern(arg.name)), arg.v.i); } run_script_main(&st, rootscript); |