Browse Source

- Corrected SC_INTRAVISION not starting.
- Small cleanups (line terminators, indenting)
- Fixed crash when attempting to read a Label as a string on a script (thanks to End of Exam)
- Fixed possible crash when changing a chat-room's owner (thanks to End of Exam)


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@8639 54d463be-8e91-2dee-dedb-b68131a5f0ec

skotlex 18 years ago
parent
commit
4e9c745bdf
9 changed files with 59 additions and 54 deletions
  1. 5 0
      Changelog-Trunk.txt
  2. 7 4
      src/map/chat.c
  3. 32 31
      src/map/clif.c
  4. 1 1
      src/map/mob.h
  5. 0 1
      src/map/npc.c
  6. 0 2
      src/map/npc.h
  7. 9 12
      src/map/script.c
  8. 1 1
      src/map/script.h
  9. 4 2
      src/map/status.c

+ 5 - 0
Changelog-Trunk.txt

@@ -4,6 +4,11 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 
 2006/09/05
 2006/09/05
+	* Corrected SC_INTRAVISION not starting. [Skotlex]
+	* Fixed crash when attempting to read a Label as a string on a script
+	  (thanks to End of Exam) [Skotlex]
+	* Fixed possible crash when changing a chat-room's owner (thanks to End of
+	  Exam) [Skotlex]
 	* Fixed dispell removing SC_NOCHAT [Skotlex]
 	* Fixed dispell removing SC_NOCHAT [Skotlex]
 	* Small fix which should correct skill_attack damaging hidden characters
 	* Small fix which should correct skill_attack damaging hidden characters
 	  when it shouldn't. [Skotlex]
 	  when it shouldn't. [Skotlex]

+ 7 - 4
src/map/chat.c

@@ -145,16 +145,18 @@ int chat_leavechat(struct map_session_data *sd)
 	pc_setchatid(sd,0);
 	pc_setchatid(sd,0);
 
 
 	if(cd->users == 0 && (*cd->owner)->type==BL_PC){
 	if(cd->users == 0 && (*cd->owner)->type==BL_PC){
-			// 全員居なくなった&PCのチャットなので消す
+		//Delete empty chatroom
 		clif_clearchat(cd,0);
 		clif_clearchat(cd,0);
-		map_delobject(cd->bl.id);	// freeまでしてくれる
+		map_delobject(cd->bl.id);
 	} else {
 	} else {
 		for(i=leavechar;i < cd->users;i++)
 		for(i=leavechar;i < cd->users;i++)
 			cd->usersd[i] = cd->usersd[i+1];
 			cd->usersd[i] = cd->usersd[i+1];
 		if(leavechar==0 && (*cd->owner)->type==BL_PC){
 		if(leavechar==0 && (*cd->owner)->type==BL_PC){
-			// PCのチャットなので所有者が抜けたので位置変更
+			//Adjust Chat location after owner has been changed.
+			map_delblock( &cd->bl );
 			cd->bl.x=cd->usersd[0]->bl.x;
 			cd->bl.x=cd->usersd[0]->bl.x;
 			cd->bl.y=cd->usersd[0]->bl.y;
 			cd->bl.y=cd->usersd[0]->bl.y;
+			map_addblock( &cd->bl );
 		}
 		}
 		clif_dispchat(cd,0);
 		clif_dispchat(cd,0);
 	}
 	}
@@ -197,9 +199,10 @@ int chat_changechatowner(struct map_session_data *sd,char *nextownername)
 	cd->usersd[0] = cd->usersd[nextowner];
 	cd->usersd[0] = cd->usersd[nextowner];
 	cd->usersd[nextowner] = tmp_sd;
 	cd->usersd[nextowner] = tmp_sd;
 
 
-	// 新しい所有者の位置へ変更
+	map_delblock( &cd->bl );
 	cd->bl.x=cd->usersd[0]->bl.x;
 	cd->bl.x=cd->usersd[0]->bl.x;
 	cd->bl.y=cd->usersd[0]->bl.y;
 	cd->bl.y=cd->usersd[0]->bl.y;
+	map_addblock( &cd->bl );
 
 
 	// 再度表示
 	// 再度表示
 	clif_dispchat(cd,0);
 	clif_dispchat(cd,0);

+ 32 - 31
src/map/clif.c

@@ -11707,39 +11707,40 @@ int clif_parse(int fd) {
 	if ((int)RFIFOREST(fd) < packet_len)
 	if ((int)RFIFOREST(fd) < packet_len)
 		return 0; // まだ1パケット分データが揃ってない
 		return 0; // まだ1パケット分データが揃ってない
 
 
-	#if DUMP_ALL_PACKETS
+#if DUMP_ALL_PACKETS
+	{
+		int i;
+		FILE *fp;
+		char packet_txt[256] = "save/packet.txt";
+		time_t now;
 		dump = 1;
 		dump = 1;
-				int i;
-				FILE *fp;
-				char packet_txt[256] = "save/packet.txt";
-				time_t now;
-				dump = 1;
-
-				if ((fp = fopen(packet_txt, "a")) == NULL) {
-					ShowError("clif.c: cant write [%s] !!! data is lost !!!\n", packet_txt);
-					return 1;
-				} else {
-					time(&now);
-					if (sd && sd->state.auth) {
-						if (sd->status.name != NULL)
-							fprintf(fp, "%sPlayer with account ID %d (character ID %d, player name %s) sent packet:\n",
-							        asctime(localtime(&now)), sd->status.account_id, sd->status.char_id, sd->status.name);
-						else
-							fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
-					} else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
-						fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
 
 
-					fprintf(fp, "\tsession #%d, packet 0x%04x, length %d, version %d\n", fd, cmd, packet_len, packet_ver);
-					fprintf(fp, "\t---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
-					for(i = 0; i < packet_len; i++) {
-						if ((i & 15) == 0)
-							fprintf(fp, "\n\t%04X ", i);
-						fprintf(fp, "%02X ", RFIFOB(fd,i));
-					}
-					fprintf(fp, "\n\n");
-					fclose(fp);
-				}
-	#endif
+		if ((fp = fopen(packet_txt, "a")) == NULL) {
+			ShowError("clif.c: cant write [%s] !!! data is lost !!!\n", packet_txt);
+			return 1;
+		} else {
+			time(&now);
+			if (sd && sd->state.auth) {
+				if (sd->status.name != NULL)
+					fprintf(fp, "%sPlayer with account ID %d (character ID %d, player name %s) sent packet:\n",
+							  asctime(localtime(&now)), sd->status.account_id, sd->status.char_id, sd->status.name);
+				else
+					fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
+			} else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
+				fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
+
+			fprintf(fp, "\tsession #%d, packet 0x%04x, length %d, version %d\n", fd, cmd, packet_len, packet_ver);
+			fprintf(fp, "\t---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
+			for(i = 0; i < packet_len; i++) {
+				if ((i & 15) == 0)
+					fprintf(fp, "\n\t%04X ", i);
+				fprintf(fp, "%02X ", RFIFOB(fd,i));
+			}
+			fprintf(fp, "\n\n");
+			fclose(fp);
+		}
+	}
+#endif
 
 
 	if (sd && sd->state.auth == 1 && sd->state.waitingdisconnect == 1) { // 切断待ちの場合パケットを処理しない
 	if (sd && sd->state.auth == 1 && sd->state.waitingdisconnect == 1) { // 切断待ちの場合パケットを処理しない
 
 

+ 1 - 1
src/map/mob.h

@@ -144,7 +144,7 @@ int mobdb_searchname(const char *str);
 int mobdb_searchname_array(struct mob_db** data, int size, const char *str);
 int mobdb_searchname_array(struct mob_db** data, int size, const char *str);
 int mobdb_checkid(const int id);
 int mobdb_checkid(const int id);
 struct view_data* mob_get_viewdata(int class_);
 struct view_data* mob_get_viewdata(int class_);
-struct mob_data *mob_once_spawn_sub(struct block_list *bl, int m,

+struct mob_data *mob_once_spawn_sub(struct block_list *bl, int m,
 	short x, short y, const char *mobname, int class_, const char *event);
 	short x, short y, const char *mobname, int class_, const char *event);
 int mob_once_spawn(struct map_session_data *sd,char *mapname,
 int mob_once_spawn(struct map_session_data *sd,char *mapname,
 	short x,short y,const char *mobname,int class_,int amount,const char *event);
 	short x,short y,const char *mobname,int class_,int amount,const char *event);

+ 0 - 1
src/map/npc.c

@@ -52,7 +52,6 @@ static int npc_mob=0;
 static int npc_delay_mob=0;
 static int npc_delay_mob=0;
 static int npc_cache_mob=0;
 static int npc_cache_mob=0;
 char *current_file = NULL;
 char *current_file = NULL;
-//int dummy_npc_id=0;
 int npc_get_new_npc_id(void){ return npc_id++; }
 int npc_get_new_npc_id(void){ return npc_id++; }
 
 
 static struct dbt *ev_db;
 static struct dbt *ev_db;

+ 0 - 2
src/map/npc.h

@@ -81,8 +81,6 @@ int npc_unload(struct npc_data *nd);
 int npc_reload(void);
 int npc_reload(void);
 int npc_script_event(TBL_PC* sd, int type);
 int npc_script_event(TBL_PC* sd, int type);
 
 
-extern int dummy_npc_id;
-
 extern char *current_file;
 extern char *current_file;
 
 
 struct npc_data *fake_nd;
 struct npc_data *fake_nd;

+ 9 - 12
src/map/script.c

@@ -559,8 +559,7 @@ unsigned char* parse_simpleexpr(unsigned char *p)
 		int c,l;
 		int c,l;
 		char *p2;
 		char *p2;
 		// label , register , function etc
 		// label , register , function etc
-		//From what I read, jA figured a better way to handle empty parenthesis '()'
-		if(skip_word(p)==p/* && !(*p==')' && p[-1]=='(')*/){
+		if(skip_word(p)==p){
 			disp_error_message("unexpected character",p);
 			disp_error_message("unexpected character",p);
 			exit(1);
 			exit(1);
 		}
 		}
@@ -1494,7 +1493,6 @@ static void read_constdb(void)
 		type=0;
 		type=0;
 		if(sscanf(line,"%[A-Za-z0-9_],%[0-9xXA-Fa-f],%d",name,val,&type)>=2 ||
 		if(sscanf(line,"%[A-Za-z0-9_],%[0-9xXA-Fa-f],%d",name,val,&type)>=2 ||
 		   sscanf(line,"%[A-Za-z0-9_] %[0-9xXA-Fa-f] %d",name,val,&type)>=2){
 		   sscanf(line,"%[A-Za-z0-9_] %[0-9xXA-Fa-f] %d",name,val,&type)>=2){
-
 			for(i=0;name[i];i++)
 			for(i=0;name[i];i++)
 				name[i]=tolower(name[i]);
 				name[i]=tolower(name[i]);
 			n=add_str((const unsigned char *) name);
 			n=add_str((const unsigned char *) name);
@@ -1929,12 +1927,13 @@ char* conv_str(struct script_state *st,struct script_data *data)
 		snprintf(buf,ITEM_NAME_LENGTH, "%d",data->u.num);
 		snprintf(buf,ITEM_NAME_LENGTH, "%d",data->u.num);
 		data->type=C_STR;
 		data->type=C_STR;
 		data->u.str=buf;
 		data->u.str=buf;
-#if 1
+	} else if(data->type==C_POS) {
+		// Protect form crashes by passing labels to string-expected args [jA2200]
+		data->type = C_CONSTSTR;
+		data->u.str = "** SCRIPT ERROR **";
 	} else if(data->type==C_NAME){
 	} else if(data->type==C_NAME){
-		// テンポラリ。本来無いはず
 		data->type=C_CONSTSTR;
 		data->type=C_CONSTSTR;
 		data->u.str=str_buf+str_data[data->u.num].str;
 		data->u.str=str_buf+str_data[data->u.num].str;
-#endif
 	}
 	}
 	return data->u.str;
 	return data->u.str;
 }
 }
@@ -2630,10 +2629,10 @@ void run_script_main(struct script_state *st)
 				if(stack->sp > stack->defsp)
 				if(stack->sp > stack->defsp)
 				{	//sp > defsp is valid in cases when you invoke functions and don't use the returned value. [Skotlex]
 				{	//sp > defsp is valid in cases when you invoke functions and don't use the returned value. [Skotlex]
 					//Since sp is supposed to be defsp in these cases, we could assume the extra stack elements are unneeded.
 					//Since sp is supposed to be defsp in these cases, we could assume the extra stack elements are unneeded.
-					if (battle_config.etc_log)
-					{
-						ShowWarning("Clearing unused stack stack.sp(%d) -> default(%d)\n",stack->sp,stack->defsp);
-						report_src(st);
+					if (battle_config.etc_log)
+					{
+						ShowWarning("Clearing unused stack stack.sp(%d) -> default(%d)\n",stack->sp,stack->defsp);
+						report_src(st);
 					}
 					}
 					pop_stack(stack, stack->defsp, stack->sp); //Clear out the unused stack-section.
 					pop_stack(stack, stack->defsp, stack->sp); //Clear out the unused stack-section.
 				} else if(battle_config.error_log)
 				} else if(battle_config.error_log)
@@ -2791,7 +2790,6 @@ int mapreg_setreg(int num,int val)
 			}
 			}
 		}
 		}
 #endif
 #endif
-	// else
 	} else { // [zBuffer]
 	} else { // [zBuffer]
 #if !defined(TXT_ONLY) && defined(MAPREGSQL)
 #if !defined(TXT_ONLY) && defined(MAPREGSQL)
 		if(name[1] != '@') { // Remove from database because it is unused.
 		if(name[1] != '@') { // Remove from database because it is unused.
@@ -11715,7 +11713,6 @@ int buildin_axtoi(struct script_state *st)
 	return 0;
 	return 0;
 }
 }
 
 
-
 // [zBuffer] List of player cont commands --->
 // [zBuffer] List of player cont commands --->
 int buildin_rid2name(struct script_state *st){
 int buildin_rid2name(struct script_state *st){
 	struct block_list *bl = NULL;
 	struct block_list *bl = NULL;

+ 1 - 1
src/map/script.h

@@ -35,7 +35,7 @@ struct script_data {
 		int num;
 		int num;
 		char *str;
 		char *str;
 	} u;
 	} u;
-	struct linkdb_node** ref; // ƒŠƒtƒ@ƒŒƒ“ƒX
+	struct linkdb_node** ref;
 };
 };
 
 
 // Moved defsp from script_state to script_stack since
 // Moved defsp from script_state to script_stack since

+ 4 - 2
src/map/status.c

@@ -5561,9 +5561,11 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
 			if (map[bl->m].flag.pvp)
 			if (map[bl->m].flag.pvp)
 				tick /=2;
 				tick /=2;
 			break;
 			break;
+		case SC_INTRAVISION:
 		case SC_ARMOR_ELEMENT:
 		case SC_ARMOR_ELEMENT:
-			break; // It just change the armor element of the player (used by battle_attr_fix)
-				   // So it has no SCB and no skill associated (used by potion scripts)
+			//Place here SCs that have no SCB_* data, no skill associated, no ICON
+			//associated, and yet are not wrong/unknown. [Skotlex]
+			break;
 		default:
 		default:
 			if (calc_flag == SCB_NONE &&
 			if (calc_flag == SCB_NONE &&
 				StatusSkillChangeTable[type]==0 &&
 				StatusSkillChangeTable[type]==0 &&