Pārlūkot izejas kodu

Cleaned up script command argument parsing (#3910)

* Cleaned up the way script commands parse arguments.
* script_isstring and script_isint will now properly check variable references.
* This allows script command arguments to contain variables without having to make source side adjustments.
* Reverted several script commands that reference the data directly.
Thanks to @Lemongrass3110!
Aleos 6 gadi atpakaļ
vecāks
revīzija
1f97beae27
4 mainītis faili ar 161 papildinājumiem un 267 dzēšanām
  1. 2 2
      src/map/pc.cpp
  2. 3 2
      src/map/pc.hpp
  3. 154 261
      src/map/script.cpp
  4. 2 2
      src/map/script.hpp

+ 2 - 2
src/map/pc.cpp

@@ -2318,13 +2318,13 @@ static void pc_bonus_item_drop(std::vector<s_add_drop> &drop, unsigned short nam
  * @param script: Script to execute
  * @param rate: Success chance
  * @param dur: Duration
- * @param flag: Battle flag
+ * @param flag: Battle flag/skill
  * @param other_script: Secondary script to execute
  * @param pos: Item equip position
  * @param onskill: Skill used to trigger autobonus
  * @return True on success or false otherwise
  */
-bool pc_addautobonus(std::vector<s_autobonus> &bonus, const char *script, short rate, unsigned int dur, short flag, const char *other_script, unsigned int pos, bool onskill)
+bool pc_addautobonus(std::vector<s_autobonus> &bonus, const char *script, short rate, unsigned int dur, uint16 flag, const char *other_script, unsigned int pos, bool onskill)
 {
 	if (bonus.size() == MAX_PC_BONUS) {
 		ShowWarning("pc_addautobonus: Reached max (%d) number of autobonus per character!\n", MAX_PC_BONUS);

+ 3 - 2
src/map/pc.hpp

@@ -195,7 +195,8 @@ struct s_add_drop {
 
 /// AutoBonus bonus struct
 struct s_autobonus {
-	short rate,atk_type;
+	short rate;
+	uint16 atk_type;
 	unsigned int duration;
 	char *bonus_script, *other_script;
 	int active;
@@ -1070,7 +1071,7 @@ bool pc_adoption(struct map_session_data *p1_sd, struct map_session_data *p2_sd,
 
 void pc_updateweightstatus(struct map_session_data *sd);
 
-bool pc_addautobonus(std::vector<s_autobonus> &bonus, const char *script, short rate, unsigned int dur, short atk_type, const char *o_script, unsigned int pos, bool onskill);
+bool pc_addautobonus(std::vector<s_autobonus> &bonus, const char *script, short rate, unsigned int dur, uint16 atk_type, const char *o_script, unsigned int pos, bool onskill);
 void pc_exeautobonus(struct map_session_data* sd, std::vector<s_autobonus> *bonus, struct s_autobonus *autobonus);
 TIMER_FUNC(pc_endautobonus);
 void pc_delautobonus(struct map_session_data* sd, std::vector<s_autobonus> &bonus, bool restore);

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 154 - 261
src/map/script.cpp


+ 2 - 2
src/map/script.hpp

@@ -46,8 +46,8 @@
 /// Pushes a copy of the data in the target index
 #define script_pushcopy(st,i) push_copy((st)->stack, (st)->start + (i))
 
-#define script_isstring(st,i) data_isstring(script_getdata(st,i))
-#define script_isint(st,i) data_isint(script_getdata(st,i))
+#define script_isstring(st,i) data_isstring(get_val(st, script_getdata(st,i)))
+#define script_isint(st,i) data_isint(get_val(st, script_getdata(st,i)))
 
 #define script_getnum(st,val) conv_num(st, script_getdata(st,val))
 #define script_getstr(st,val) conv_str(st, script_getdata(st,val))

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels