summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-01-26 09:44:10 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-01-26 09:44:10 +0000
commit5514b1d63acfbe0fa0e51a855679769d4f013e35 (patch)
tree6c7e084b8b95398e2e35d9ca867a6d3e2af674e5 /src
parentcece111a565a6d53790248eaa01bf68615d3a4b1 (diff)
downloadhercules-5514b1d63acfbe0fa0e51a855679769d4f013e35.tar.gz
hercules-5514b1d63acfbe0fa0e51a855679769d4f013e35.tar.bz2
hercules-5514b1d63acfbe0fa0e51a855679769d4f013e35.tar.xz
hercules-5514b1d63acfbe0fa0e51a855679769d4f013e35.zip
Some random cleaning
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12141 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/map/atcommand.c8
-rw-r--r--src/map/clif.c31
-rw-r--r--src/map/clif.h2
-rw-r--r--src/map/map.c59
-rw-r--r--src/map/map.h3
-rw-r--r--src/map/party.c2
6 files changed, 37 insertions, 68 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index ea8a1d163..fcba7b5dd 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -3663,7 +3663,7 @@ int atcommand_kick(const int fd, struct map_session_data* sd, const char* comman
return -1;
}
- clif_GM_kick(sd, pl_sd, 1);
+ clif_GM_kick(sd, pl_sd);
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++) {
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)
- 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);
for (i = 0; i < users; i++) {
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();
diff --git a/src/map/clif.c b/src/map/clif.c
index fd8b2e076..5700aa435 100644
--- a/src/map/clif.c
+++ b/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;
clif_getareachar_pc(sd, tsd);
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)
- clif_specialeffect_single(bl, 421, sd->fd);
+ clif_specialeffect_single(bl,421,sd->fd);
}
break;
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;
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)
- clif_specialeffect_single(bl, 421, sd->fd);
+ clif_specialeffect_single(bl,421,sd->fd);
}
break;
case BL_PET:
@@ -6880,7 +6880,7 @@ int clif_GM_kickack(struct map_session_data *sd, int id)
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;
@@ -6889,10 +6889,8 @@ int clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd,int ty
else
map_quit(tsd);
- if( type )
+ if( sd )
clif_GM_kickack(sd,tsd->status.account_id);
-
- return 0;
}
/// 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);
- 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);
if((select > sd->npc_menu && select != 0xff) || !select){
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 {
sd->npc_menu=select;
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);
return;
}
- clif_GM_kick(sd, tsd, 1);
+ clif_GM_kick(sd, tsd);
if(log_config.gm && lv >= log_config.gm) {
char message[256];
sprintf(message, "/kick %s (%d)", tsd->status.name, tsd->status.char_id);
diff --git a/src/map/clif.h b/src/map/clif.h
index b93321985..8a0cd10a9 100644
--- a/src/map/clif.h
+++ b/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_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_GM_silence(struct map_session_data* sd, struct map_session_data* tsd, uint8 type);
int clif_timedout(struct map_session_data *sd);
diff --git a/src/map/map.c b/src/map/map.c
index e713b7d4a..3900247fe 100644
--- a/src/map/map.c
+++ b/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.
if (all_count < 1)
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))
{
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);
if (*users > (signed int)all_count) //Which should be impossible...
*users = all_count;
+
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 i;
- if(m<0 || m>=map_num)
+ if( m < 0 || m >= map_num )
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);
return -1;
}
- if(i==map[m].npc_num){
+
+ if( i == map[m].npc_num )
map[m].npc_num++;
- }
nullpo_retr(0, nd);
@@ -1841,44 +1843,19 @@ int map_addnpc(int m,struct npc_data *nd)
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]
*-----------------------------------------*/
-// 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)
{
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;
}
diff --git a/src/map/map.h b/src/map/map.h
index 0ae13ad95..fc67a5387 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -503,9 +503,6 @@ struct homunculus_db; //[orn]
struct item_data;
struct square;
-// The player performed a suspicious action (not used right now) [FlavioJS]
-#define LOG_SUSPICIOUS(sd,msg)
-
struct map_session_data {
struct block_list bl;
struct unit_data ud;
diff --git a/src/map/party.c b/src/map/party.c
index 1b3a9eaf7..0f042db89 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -145,7 +145,7 @@ int party_check_member(struct party *p)
nullpo_retr(0, p);
all_sd = map_getallusers(&users);
-
+
for(i=0;i<users;i++)
{
sd = all_sd[i];