浏览代码

- Added overflow protection to @main whisper parsing.
- Fixed a bug in slaves_inherit_speed
- Miscellanous silly cleanups (format, unnecessary assignments, comments, etc)


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

skotlex 18 年之前
父节点
当前提交
b421d38216
共有 5 个文件被更改,包括 39 次插入38 次删除
  1. 2 1
      src/map/battle.c
  2. 1 1
      src/map/battle.h
  3. 5 5
      src/map/clif.c
  4. 30 30
      src/map/script.c
  5. 1 1
      src/map/status.c

+ 2 - 1
src/map/battle.c

@@ -1600,6 +1600,7 @@ static struct Damage battle_calc_weapon_attack(
 					break;
 				case HFLI_SBR44:	//[orn]
 					skillratio += 100 *(skill_lv-1);
+					break;
 			}
 
 			ATK_RATE(skillratio);
@@ -3226,7 +3227,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
 				return 0;
 		}
 			break;
-		//Valid targets with nothing else specified.
+		//Valid targets with no special checks here.
 		case BL_HOM:
 			break;
 		//All else not specified is an invalid target.

+ 1 - 1
src/map/battle.h

@@ -355,7 +355,7 @@ extern struct Battle_Config {
 	unsigned short pk_min_level; // [celest]
 	unsigned short skill_steal_type; // [celest]
 	unsigned short skill_steal_rate; // [celest]
-	unsigned short skill_steal_max_tries; //max steal skill tries on a mob. if 0 or 256, then w/o limit [Lupus]
+	unsigned short skill_steal_max_tries; //max steal skill tries on a mob. if 0, then w/o limit [Lupus]
 	unsigned short motd_type; // [celest]
 	unsigned short finding_ore_rate; // orn
 	unsigned short exp_calc_type;

+ 5 - 5
src/map/clif.c

@@ -9168,7 +9168,7 @@ void clif_parse_Wis(int fd, struct map_session_data *sd) { // S 0096 <len>.w <ni
 			for (i=0;i<10;i++)
 			{
 				sprintf(output, "@whispervar%d$", i);
-				set_var(sd,output,(char *) split_data[i]);        
+				set_var(sd,output,(char *) split_data[i]);
 			}
 			
 			sprintf(output, "%s::OnWhisperGlobal", npc->name);
@@ -9184,7 +9184,7 @@ void clif_parse_Wis(int fd, struct map_session_data *sd) { // S 0096 <len>.w <ni
 		if(!sd->state.mainchat)
 			clif_displaymessage(fd, msg_txt(388)); // You should enable main chat with "@main on" command.
 		else {
-			sprintf(output, msg_txt(386), sd->status.name, msg);
+			snprintf(output, sizeof(output)/sizeof(char), msg_txt(386), sd->status.name, msg);
 			intif_announce(output, strlen(output) + 1, 0xFE000000, 0);
 		}
 		aFree(command);
@@ -11131,7 +11131,7 @@ void clif_parse_PMIgnore(int fd, struct map_session_data *sd) {	// Rewritten by
 	WFIFOW(fd,0) = 0x0d1; // R 00d1 <type>.B <fail>.B: type: 0: deny, 1: allow, fail: 0: success, 1: fail
 	WFIFOB(fd,2) = RFIFOB(fd,26);
 	// do nothing only if nick can not exist
-	if ((i = strlen(nick)) < 4) {
+	if (strlen(nick) < 4) {
 		WFIFOB(fd,3) = 1; // fail
 		WFIFOSET(fd, packet_len_table[0x0d1]);
 		clif_wis_message(fd, wisp_server_name,
@@ -11239,7 +11239,7 @@ void clif_parse_PMIgnoreAll(int fd, struct map_session_data *sd) { // Rewritten
 		sd->state.ignoreAll = 1;
 		WFIFOB(fd,3) = 0; // success
 		WFIFOSET(fd, packet_len_table[0x0d2]);
-		return ;
+		return;
 	}
 	//Unblock everyone
 	if (!sd->state.ignoreAll) {
@@ -11982,7 +11982,7 @@ int clif_parse(int fd) {
 	}
 #if DUMP_UNKNOWN_PACKET
 	else if (battle_config.error_log)
-  	{
+	{
 		int i;
 		FILE *fp;
 		char packet_txt[256] = "save/packet.txt";

+ 30 - 30
src/map/script.c

@@ -7429,36 +7429,36 @@ int buildin_getusersname(struct script_state *st)
 	}
 	return 0;
 }
-/*==========================================
- * getmapguildusers("mapname.gat",guild ID) Returns the number guild members present on a map [Reddozen]
- *------------------------------------------
- */
-int buildin_getmapguildusers(struct script_state *st) {
-	char *str;
-	int m, gid;
-	int i=0,c=0;
-	struct guild *g = NULL;
-	str=conv_str(st, &(st->stack->stack_data[st->start+2]));
-	gid=conv_num(st, &(st->stack->stack_data[st->start+3]));
-	if ((m = map_mapname2mapid(str)) < 0) { // map id on this server (m == -1 if not in actual map-server)
-		push_val(st->stack, C_INT, -1);
-		return 0;
-	}
-	g = guild_search(gid);
-
-	if (g){
-		for(i = 0; i < g->max_member; i++)
-		{
-			if (g->member[i].sd )
-			{
-				if(g->member[i].sd->bl.m == m)
-					c++;
-			}
-		}
-	}
-
-	push_val(st->stack, C_INT, c);
-	return 0;
+/*==========================================
+ * getmapguildusers("mapname.gat",guild ID) Returns the number guild members present on a map [Reddozen]
+ *------------------------------------------
+ */
+int buildin_getmapguildusers(struct script_state *st) {
+	char *str;
+	int m, gid;
+	int i=0,c=0;
+	struct guild *g = NULL;
+	str=conv_str(st, &(st->stack->stack_data[st->start+2]));
+	gid=conv_num(st, &(st->stack->stack_data[st->start+3]));
+	if ((m = map_mapname2mapid(str)) < 0) { // map id on this server (m == -1 if not in actual map-server)
+		push_val(st->stack, C_INT, -1);
+		return 0;
+	}
+	g = guild_search(gid);
+
+	if (g){
+		for(i = 0; i < g->max_member; i++)
+		{
+			if (g->member[i].sd )
+			{
+				if(g->member[i].sd->bl.m == m)
+					c++;
+			}
+		}
+	}
+
+	push_val(st->stack, C_INT, c);
+	return 0;
 }
 /*==========================================
  * マップ指定ユーザー数所得

+ 1 - 1
src/map/status.c

@@ -1321,7 +1321,7 @@ int status_calc_mob(struct mob_data* md, int first)
 	if (flag&8 && mbl) {
 		struct status_data *mstatus = status_get_base_status(mbl);
 		if (mstatus &&
-			battle_config.slaves_inherit_speed&(status->mode&MD_CANMOVE?1:2))
+			battle_config.slaves_inherit_speed&(mstatus->mode&MD_CANMOVE?1:2))
 			status->speed = mstatus->speed;
 	}