浏览代码

Some random cleaning

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12141 54d463be-8e91-2dee-dedb-b68131a5f0ec
ultramage 17 年之前
父节点
当前提交
c53f4f1955
共有 10 个文件被更改,包括 44 次插入75 次删除
  1. 4 4
      npc/merchants/shops.txt
  2. 1 1
      npc/warps/cities/comodo.txt
  3. 1 1
      npc/warps/dungeons/odin.txt
  4. 1 1
      npc/warps/dungeons/xmas_dun.txt
  5. 4 4
      src/map/atcommand.c
  6. 13 18
      src/map/clif.c
  7. 1 1
      src/map/clif.h
  8. 18 41
      src/map/map.c
  9. 0 3
      src/map/map.h
  10. 1 1
      src/map/party.c

+ 4 - 4
npc/merchants/shops.txt

@@ -114,9 +114,9 @@ geffen,193,152,4	shop	Pet Groomer#gef	124,537:-1,643:-1,10013:-1,10014:-1
 //=======================================================
 //=======================================================
 // Gonryun
 // Gonryun
 //=======================================================
 //=======================================================
-gonryun,147,84,5	shop	Tool Dealer	777,1750:-1,1770:-1,611:-1,501:-1,502:-1,503:-1,504:-1,506:-1,645:-1,656:-1,601:-1,602:-1,1065:-1
-gonryun,174,101,3	shop	Weapon Dealer	774,1207:-1,1216:-1,1107:-1,1122:-1,1116:-1,1154:-1,1407:-1,1457:-1,1354:-1,1519:-1
-gonryun,173,84,3	shop	Armor Dealer	770,2211:-1,2401:-1,2403:-1,2501:-1,2503:-1,2101:-1,2103:-1,2305:-1,2321:-1,2332:-1,2328:-1,2627:-1
+gonryun,147,84,5	shop	Tool Dealer#gon	777,1750:-1,1770:-1,611:-1,501:-1,502:-1,503:-1,504:-1,506:-1,645:-1,656:-1,601:-1,602:-1,1065:-1
+gonryun,174,101,3	shop	Weapon Dealer#gon	774,1207:-1,1216:-1,1107:-1,1122:-1,1116:-1,1154:-1,1407:-1,1457:-1,1354:-1,1519:-1
+gonryun,173,84,3	shop	Armor Dealer#gon	770,2211:-1,2401:-1,2403:-1,2501:-1,2503:-1,2101:-1,2103:-1,2305:-1,2321:-1,2332:-1,2328:-1,2627:-1
 
 
 //=======================================================
 //=======================================================
 // Hugel
 // Hugel
@@ -136,7 +136,7 @@ izlude_in,60,127,4	shop	Weapon Dealer#iz	72,1750:-1,1751:-1,1701:-1,1601:-1,1201
 izlude_in,70,127,4	shop	Armor Dealer#iz	62,2103:-1,2105:-1,2403:-1,2405:-1,2503:-1,2505:-1,2226:-1,2228:-1,2303:-1,2305:-1,2328:-1,2307:-1,2309:-1,2312:-1,2314:-1,2316:-1,2628:-1
 izlude_in,70,127,4	shop	Armor Dealer#iz	62,2103:-1,2105:-1,2403:-1,2405:-1,2503:-1,2505:-1,2226:-1,2228:-1,2303:-1,2305:-1,2328:-1,2307:-1,2309:-1,2312:-1,2314:-1,2316:-1,2628:-1
 izlude_in,115,61,0	shop	Tool Dealer#iz	47,611:-1,501:-1,502:-1,503:-1,504:-1,506:-1,645:-1,656:-1,601:-1,602:-1,1065:-1,1750:-1
 izlude_in,115,61,0	shop	Tool Dealer#iz	47,611:-1,501:-1,502:-1,503:-1,504:-1,506:-1,645:-1,656:-1,601:-1,602:-1,1065:-1,1750:-1
 izlude,105,99,0	shop	Butcher#iz	54,517:-1
 izlude,105,99,0	shop	Butcher#iz	54,517:-1
-izlude,94,98,4	shop	Fruit Gardene#izr	53,512:-1,513:-1,515:-1,516:-1
+izlude,94,98,4	shop	Fruit Gardene#iz	53,512:-1,513:-1,515:-1,516:-1
 izlude,105,92,7	shop	Vendor from Milk Ranch#i	90,519:-1
 izlude,105,92,7	shop	Vendor from Milk Ranch#i	90,519:-1
 izlude,164,138,4	shop	Pet Groomer#iz	124,537:-1,643:-1,10013:-1,10014:-1
 izlude,164,138,4	shop	Pet Groomer#iz	124,537:-1,643:-1,10013:-1,10014:-1
 
 

+ 1 - 1
npc/warps/cities/comodo.txt

@@ -42,4 +42,4 @@ cmd_in02,74,21,0	warp	cmd_casino4-2	1,1,comodo,140,86
 cmd_in02,168,113,0	warp	cmd_casino5-1	1,1,cmd_in02,63,73
 cmd_in02,168,113,0	warp	cmd_casino5-1	1,1,cmd_in02,63,73
 cmd_in02,58,74,0	warp	cmd_casino5-2	1,1,cmd_in02,166,116
 cmd_in02,58,74,0	warp	cmd_casino5-2	1,1,cmd_in02,166,116
 cmd_in02,187,78,0	warp	cmd_casino6-1	1,1,cmd_in02,84,37
 cmd_in02,187,78,0	warp	cmd_casino6-1	1,1,cmd_in02,84,37
-cmd_in02,90,37,0	warp	cmd_casino6-2	1,1,cmd_in02,191,77
+cmd_in02,90,37,0	warp	cmd_casino6-2	1,1,cmd_in02,191,77

+ 1 - 1
npc/warps/dungeons/odin.txt

@@ -24,4 +24,4 @@ odin_tem02,21,334,0	warp	odin04	1,1,odin_tem01,379,334
 odin_tem02,153,349,0	warp	odin05	1,1,odin_tem03,120,54
 odin_tem02,153,349,0	warp	odin05	1,1,odin_tem03,120,54
 odin_tem03,121,49,0	warp	odin06	1,1,odin_tem02,154,345
 odin_tem03,121,49,0	warp	odin06	1,1,odin_tem02,154,345
 odin_tem02,261,377,0	warp	odin07	1,1,odin_tem03,247,40
 odin_tem02,261,377,0	warp	odin07	1,1,odin_tem03,247,40
-odin_tem03,247,34,0	warp	odin08	1,1,odin_tem02,263,372
+odin_tem03,247,34,0	warp	odin08	1,1,odin_tem02,263,372

+ 1 - 1
npc/warps/dungeons/xmas_dun.txt

@@ -16,4 +16,4 @@
 xmas,143,314,0	warp	xmas_dun1-1	1,1,xmas_dun01,205,16
 xmas,143,314,0	warp	xmas_dun1-1	1,1,xmas_dun01,205,16
 xmas_dun01,205,13,0	warp	xmas_dun1-2	1,1,xmas,143,311
 xmas_dun01,205,13,0	warp	xmas_dun1-2	1,1,xmas,143,311
 xmas_dun01,129,130,0	warp	xmas_dun2-1	1,1,xmas_dun02,131,130
 xmas_dun01,129,130,0	warp	xmas_dun2-1	1,1,xmas_dun02,131,130
-xmas_dun02,129,130,0	warp	xmas_dun2-2	1,1,xmas_dun01,132,130
+xmas_dun02,129,130,0	warp	xmas_dun2-2	1,1,xmas_dun01,132,130

+ 4 - 4
src/map/atcommand.c

@@ -3663,7 +3663,7 @@ int atcommand_kick(const int fd, struct map_session_data* sd, const char* comman
 		return -1;
 		return -1;
 	}
 	}
 	
 	
-	clif_GM_kick(sd, pl_sd, 1);
+	clif_GM_kick(sd, pl_sd);
 	
 	
 	return 0;
 	return 0;
 }
 }
@@ -3682,7 +3682,7 @@ int atcommand_kickall(const int fd, struct map_session_data* sd, const char* com
 	for (i = 0; i < users; i++) {
 	for (i = 0; i < users; i++) {
 		if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
 		if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
 			if (sd->status.account_id != pl_sd->status.account_id)
 			if (sd->status.account_id != pl_sd->status.account_id)
-				clif_GM_kick(sd, pl_sd, 0);
+				clif_GM_kick(NULL, pl_sd);
 		}
 		}
 	}
 	}
 
 
@@ -3899,9 +3899,9 @@ int atcommand_mapexit(const int fd, struct map_session_data* sd, const char* com
 	pl_allsd = map_getallusers(&users);
 	pl_allsd = map_getallusers(&users);
 	for (i = 0; i < users; i++) {
 	for (i = 0; i < users; i++) {
 		if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
 		if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
-			clif_GM_kick(sd, pl_sd, 0);
+			clif_GM_kick(NULL, pl_sd);
 	}
 	}
-	clif_GM_kick(sd, sd, 0);
+	clif_GM_kick(NULL, sd);
 	
 	
 	flush_fifos();
 	flush_fifos();
 
 

+ 13 - 18
src/map/clif.c

@@ -3434,9 +3434,9 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl)
 			TBL_PC* tsd = (TBL_PC*)bl;
 			TBL_PC* tsd = (TBL_PC*)bl;
 			clif_getareachar_pc(sd, tsd);
 			clif_getareachar_pc(sd, tsd);
 			if(tsd->state.size==2) // tiny/big players [Valaris]
 			if(tsd->state.size==2) // tiny/big players [Valaris]
-				clif_specialeffect_single(bl, 423, sd->fd);
+				clif_specialeffect_single(bl,423,sd->fd);
 			else if(tsd->state.size==1)
 			else if(tsd->state.size==1)
-				clif_specialeffect_single(bl, 421, sd->fd);
+				clif_specialeffect_single(bl,421,sd->fd);
 		}
 		}
 		break;
 		break;
 	case BL_NPC:
 	case BL_NPC:
@@ -3450,9 +3450,9 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl)
 		{
 		{
 			TBL_MOB* md = (TBL_MOB*)bl;
 			TBL_MOB* md = (TBL_MOB*)bl;
 			if(md->special_state.size==2) // tiny/big mobs [Valaris]
 			if(md->special_state.size==2) // tiny/big mobs [Valaris]
-				clif_specialeffect_single(bl, 423, sd->fd);
+				clif_specialeffect_single(bl,423,sd->fd);
 			else if(md->special_state.size==1)
 			else if(md->special_state.size==1)
-				clif_specialeffect_single(bl, 421, sd->fd);
+				clif_specialeffect_single(bl,421,sd->fd);
 		}
 		}
 		break;
 		break;
 	case BL_PET:
 	case BL_PET:
@@ -6880,7 +6880,7 @@ int clif_GM_kickack(struct map_session_data *sd, int id)
 	return 0;
 	return 0;
 }
 }
 
 
-int clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd,int type)
+void clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd)
 {
 {
 	int fd = tsd->fd;
 	int fd = tsd->fd;
 
 
@@ -6889,10 +6889,8 @@ int clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd,int ty
 	else
 	else
 		map_quit(tsd);
 		map_quit(tsd);
 
 
-	if( type )
+	if( sd )
 		clif_GM_kickack(sd,tsd->status.account_id);
 		clif_GM_kickack(sd,tsd->status.account_id);
-
-	return 0;
 }
 }
 
 
 /// Displays various manner-related status messages
 /// Displays various manner-related status messages
@@ -9046,14 +9044,11 @@ void clif_parse_ChangeCart(int fd,struct map_session_data *sd)
 
 
 	type = (int)RFIFOW(fd,2);
 	type = (int)RFIFOW(fd,2);
 
 
-	if( (type == 5 && sd->status.base_level <= 90) ||
-		(type == 4 && sd->status.base_level <= 80) ||
-		(type == 3 && sd->status.base_level <= 65) ||
-		(type == 2 && sd->status.base_level <= 40) ||
-		pc_setcart(sd,type) )
-	{
-		LOG_SUSPICIOUS(sd,"clif_parse_ChangeCart");
-	}
+	if( (type == 5 && sd->status.base_level > 90) ||
+	    (type == 4 && sd->status.base_level > 80) ||
+	    (type == 3 && sd->status.base_level > 65) ||
+	    (type == 2 && sd->status.base_level > 40) )
+		pc_setcart(sd,type);
 }
 }
 
 
 /*==========================================
 /*==========================================
@@ -9403,7 +9398,7 @@ void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
 	select = RFIFOB(fd,6);
 	select = RFIFOB(fd,6);
 	if((select > sd->npc_menu && select != 0xff) || !select){
 	if((select > sd->npc_menu && select != 0xff) || !select){
 		ShowWarning("Hack on NPC Select Menu: %s (AID: %d)!\n",sd->status.name,sd->bl.id);
 		ShowWarning("Hack on NPC Select Menu: %s (AID: %d)!\n",sd->status.name,sd->bl.id);
-		clif_GM_kick(sd,sd,0);
+		clif_GM_kick(NULL,sd);
 	} else {
 	} else {
 		sd->npc_menu=select;
 		sd->npc_menu=select;
 		npc_scriptcont(sd,RFIFOL(fd,2));
 		npc_scriptcont(sd,RFIFOL(fd,2));
@@ -10258,7 +10253,7 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd)
 			clif_GM_kickack(sd, 0);
 			clif_GM_kickack(sd, 0);
 			return;
 			return;
 		}
 		}
-		clif_GM_kick(sd, tsd, 1);
+		clif_GM_kick(sd, tsd);
 		if(log_config.gm && lv >= log_config.gm) {
 		if(log_config.gm && lv >= log_config.gm) {
 			char message[256];
 			char message[256];
 			sprintf(message, "/kick %s (%d)", tsd->status.name, tsd->status.char_id);
 			sprintf(message, "/kick %s (%d)", tsd->status.name, tsd->status.char_id);

+ 1 - 1
src/map/clif.h

@@ -362,7 +362,7 @@ void clif_specialeffect_single(struct block_list* bl, int type, int fd);
 int clif_message(struct block_list *bl, const char* msg); // messages (from mobs/npcs) [Valaris]
 int clif_message(struct block_list *bl, const char* msg); // messages (from mobs/npcs) [Valaris]
 
 
 int clif_GM_kickack(struct map_session_data *sd,int id);
 int clif_GM_kickack(struct map_session_data *sd,int id);
-int clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd,int type);
+void clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd);
 void clif_manner_message(struct map_session_data* sd, uint32 type);
 void clif_manner_message(struct map_session_data* sd, uint32 type);
 void clif_GM_silence(struct map_session_data* sd, struct map_session_data* tsd, uint8 type);
 void clif_GM_silence(struct map_session_data* sd, struct map_session_data* tsd, uint8 type);
 int clif_timedout(struct map_session_data *sd);
 int clif_timedout(struct map_session_data *sd);

+ 18 - 41
src/map/map.c

@@ -1770,17 +1770,19 @@ struct map_session_data** map_getallusers(int *users)
 		all_count = pc_db->size(pc_db); //This is the real number of chars in the db, better use this than the actual "online" count.
 		all_count = pc_db->size(pc_db); //This is the real number of chars in the db, better use this than the actual "online" count.
 		if (all_count < 1)
 		if (all_count < 1)
 			all_count = 10; //Allow room for at least 10 chars.
 			all_count = 10; //Allow room for at least 10 chars.
-		all_sd = aCalloc(all_count, sizeof(struct map_session_data*)); //it's actually just the size of a pointer.
+		CREATE(all_sd, struct map_session_data*, all_count);
 	}
 	}
 
 
 	if (all_count < pc_db->size(pc_db))
 	if (all_count < pc_db->size(pc_db))
 	{
 	{
 		all_count = pc_db->size(pc_db)+10; //Give some room to prevent doing reallocs often.
 		all_count = pc_db->size(pc_db)+10; //Give some room to prevent doing reallocs often.
-		all_sd = aRealloc(all_sd, all_count*sizeof(struct map_session_data*));
+		RECREATE(all_sd, struct map_session_data*, all_count);
 	}
 	}
+
 	*users = pc_db->getall(pc_db,(void**)all_sd,all_count,map_getallpc_sub);
 	*users = pc_db->getall(pc_db,(void**)all_sd,all_count,map_getallpc_sub);
 	if (*users > (signed int)all_count) //Which should be impossible...
 	if (*users > (signed int)all_count) //Which should be impossible...
 		*users = all_count;
 		*users = all_count;
+
 	return all_sd;
 	return all_sd;
 }
 }
 
 
@@ -1819,18 +1821,18 @@ int map_foreachiddb(int (*func)(DBKey,void*,va_list),...)
 int map_addnpc(int m,struct npc_data *nd)
 int map_addnpc(int m,struct npc_data *nd)
 {
 {
 	int i;
 	int i;
-	if(m<0 || m>=map_num)
+	if( m < 0 || m >= map_num )
 		return -1;
 		return -1;
-	for(i=0;i<map[m].npc_num && i<MAX_NPC_PER_MAP;i++)
-		if(map[m].npc[i]==NULL)
-			break;
-	if(i==MAX_NPC_PER_MAP){
+
+	ARR_FIND( 0, MAX_NPC_PER_MAP, i, map[m].npc[i] == NULL );
+	if( i == MAX_NPC_PER_MAP )
+	{
 		ShowWarning("too many NPCs in one map %s\n",map[m].name);
 		ShowWarning("too many NPCs in one map %s\n",map[m].name);
 		return -1;
 		return -1;
 	}
 	}
-	if(i==map[m].npc_num){
+
+	if( i == map[m].npc_num )
 		map[m].npc_num++;
 		map[m].npc_num++;
-	}
 
 
 	nullpo_retr(0, nd);
 	nullpo_retr(0, nd);
 
 
@@ -1841,44 +1843,19 @@ int map_addnpc(int m,struct npc_data *nd)
 	return i;
 	return i;
 }
 }
 
 
-void map_removenpc(void)
-{
-	int i,m,n=0;
-
-	for(m=0;m<map_num;m++) {
-		for(i=0;i<map[m].npc_num && i<MAX_NPC_PER_MAP;i++) {
-			if(map[m].npc[i]!=NULL) {
-				clif_clearunit_area(&map[m].npc[i]->bl,2);
-				map_delblock(&map[m].npc[i]->bl);
-				idb_remove(id_db,map[m].npc[i]->bl.id);
-				if(map[m].npc[i]->subtype==SCRIPT) {
-					aFree(map[m].npc[i]->u.scr.script);
-					aFree(map[m].npc[i]->u.scr.label_list);
-				}
-				aFree(map[m].npc[i]);
-				map[m].npc[i] = NULL;
-				n++;
-			}
-		}
-	}
-	
-	ShowStatus("Successfully removed and freed from memory '"CL_WHITE"%d"CL_RESET"' NPCs.\n",n);
-}
-
 /*=========================================
 /*=========================================
  * Dynamic Mobs [Wizputer]
  * Dynamic Mobs [Wizputer]
  *-----------------------------------------*/
  *-----------------------------------------*/
-// allocates a struct when it there is place free in the cache,
-// and returns NULL otherwise
-// -- i'll just leave the old code in case it's needed ^^;
+// Stores the spawn data entry in the mob list.
+// Returns the index of successful, or -1 if the list was full.
 int map_addmobtolist(unsigned short m, struct spawn_data *spawn)
 int map_addmobtolist(unsigned short m, struct spawn_data *spawn)
 {
 {
 	size_t i;
 	size_t i;
-	for (i = 0; i < MAX_MOB_LIST_PER_MAP; i++) {
-		if (map[m].moblist[i] == NULL) {
-			map[m].moblist[i] = spawn;
-			return i;
-		}
+	ARR_FIND( 0, MAX_MOB_LIST_PER_MAP, i, map[m].moblist[i] == NULL );
+	if( i < MAX_MOB_LIST_PER_MAP )
+	{
+		map[m].moblist[i] = spawn;
+		return i;
 	}
 	}
 	return -1;
 	return -1;
 }
 }

+ 0 - 3
src/map/map.h

@@ -503,9 +503,6 @@ struct homunculus_db;	//[orn]
 struct item_data;
 struct item_data;
 struct square;
 struct square;
 
 
-// The player performed a suspicious action (not used right now) [FlavioJS]
-#define LOG_SUSPICIOUS(sd,msg)
-
 struct map_session_data {
 struct map_session_data {
 	struct block_list bl;
 	struct block_list bl;
 	struct unit_data ud;
 	struct unit_data ud;

+ 1 - 1
src/map/party.c

@@ -145,7 +145,7 @@ int party_check_member(struct party *p)
 	nullpo_retr(0, p);
 	nullpo_retr(0, p);
 
 
 	all_sd = map_getallusers(&users);
 	all_sd = map_getallusers(&users);
-	
+
 	for(i=0;i<users;i++)
 	for(i=0;i<users;i++)
 	{
 	{
 		sd = all_sd[i];
 		sd = all_sd[i];