Procházet zdrojové kódy

Min/max issue (#5574)

* Fixed min/max issue for zero variable value
* Added a CI test script

Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
Atemo před 4 roky
rodič
revize
ae3c6ce38b
3 změnil soubory, kde provedl 31 přidání a 1 odebrání
  1. 11 1
      doc/script_commands.txt
  2. 9 0
      npc/test/ci/5573.txt
  3. 11 0
      src/map/script.cpp

+ 11 - 1
doc/script_commands.txt

@@ -7552,7 +7552,7 @@ Example:
 
 *debugmes "<message>";
 
-This command will send the message to the server console (map-server window). It
+This command will send a debug message to the server console (map-server window). It
 will not be displayed anywhere else.
 
     // Displays "NAME has clicked me!" in the map-server window.
@@ -7560,6 +7560,16 @@ will not be displayed anywhere else.
 
 ---------------------------------------
 
+*errormes "<message>";
+
+This command will send an error message to the server console (map-server window). It
+will not be displayed anywhere else.
+
+    // Displays "NAME has clicked me!" in the map-server window.
+    errormes strcharinfo(0) + " has clicked me!";
+
+---------------------------------------
+
 *logmes "<message>";
 
 This command will write the message given to the map server NPC log file, as

+ 9 - 0
npc/test/ci/5573.txt

@@ -0,0 +1,9 @@
+-	script	Issue5573	-1,{
+OnInit:
+	.i = 0;
+	.@i = min( .i, 200 );
+	
+	if( .@i == 200 ){
+		errormes "Issue 5573 is happening again.";
+	}
+}

+ 11 - 0
src/map/script.cpp

@@ -11901,6 +11901,13 @@ BUILDIN_FUNC(debugmes)
 	return SCRIPT_CMD_SUCCESS;
 }
 
+BUILDIN_FUNC( errormes ){
+	ShowError( "%s\n", script_getstr( st, 2 ) );
+	script_reportsrc( st );
+
+	return SCRIPT_CMD_SUCCESS;
+}
+
 /*==========================================
  *------------------------------------------*/
 BUILDIN_FUNC(catchpet)
@@ -23184,6 +23191,9 @@ BUILDIN_FUNC(minmax){
 					value = func( value, get_val2_num( st, reference_uid( id, start ), reference_getref( data ) ) );
 				}
 			}
+			else {
+				value = func( value, 0 );
+			}
 		}else{
 			ShowError( "buildin_%s: not a supported data type!\n", functionname );
 			script_reportdata( data );
@@ -25129,6 +25139,7 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF(getstatus, "i??"),
 	BUILDIN_DEF(getscrate,"ii?"),
 	BUILDIN_DEF(debugmes,"s"),
+	BUILDIN_DEF(errormes,"s"),
 	BUILDIN_DEF2(catchpet,"pet","i"),
 	BUILDIN_DEF2(birthpet,"bpet",""),
 	BUILDIN_DEF(catchpet,"i"),