Selaa lähdekoodia

Fixed #647. Fail to get parameter value from `readparam` if the parameter given is constant as param-type value. So for an example, `readparam(BaseLevel)` will be fine now, the result same as like `BaseLevel` itself.

Signed-off-by: Cydh Ramdh <cydh@pservero.com>
Cydh Ramdh 9 vuotta sitten
vanhempi
commit
e112fc1c50
2 muutettua tiedostoa jossa 12 lisäystä ja 1 poistoa
  1. 3 0
      src/map/pc.c
  2. 9 1
      src/map/script.c

+ 3 - 0
src/map/pc.c

@@ -7727,6 +7727,9 @@ int pc_readparam(struct map_session_data* sd,int type)
 #else
 			val = sd->castrate; break;
 #endif
+		default:
+			ShowError("pc_readparam: Attempt to read unknown parameter '%d'.\n", type);
+			return -1;
 	}
 
 	return val;

+ 9 - 1
src/map/script.c

@@ -7748,13 +7748,21 @@ BUILDIN_FUNC(disableitemuse)
 BUILDIN_FUNC(readparam)
 {
 	int type;
+	struct script_data *data = script_getdata(st, 2);
 	TBL_PC *sd;
 
-	type = script_getnum(st,2);
 	if (!script_nick2sd(3,sd)) {
 		script_pushint(st,-1);
 		return SCRIPT_CMD_FAILURE;
 	}
+
+	if (data->type == C_NAME) { // If using constant name, just get the val
+		get_val_(st, data, sd);
+		script_pushint(st, (int)data->u.num);
+		return SCRIPT_CMD_SUCCESS;
+	}
+
+	type = script_getnum(st, 2);
 	script_pushint(st,pc_readparam(sd,type));
 	return SCRIPT_CMD_SUCCESS;
 }