summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
authorLance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-08-27 06:38:17 +0000
committerLance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-08-27 06:38:17 +0000
commit3c8999edce9e1f0d5c0dee3ff8311e781d64c684 (patch)
treed066567a720e5fad02e6f857d55bc165d9a3809a /src/map/clif.c
parentea320701794515d4ffa6a8e8ff8f3b8fdfe09860 (diff)
downloadhercules-3c8999edce9e1f0d5c0dee3ff8311e781d64c684.tar.gz
hercules-3c8999edce9e1f0d5c0dee3ff8311e781d64c684.tar.bz2
hercules-3c8999edce9e1f0d5c0dee3ff8311e781d64c684.tar.xz
hercules-3c8999edce9e1f0d5c0dee3ff8311e781d64c684.zip
* Optional macro MEMSET_TURBO for faster low-level memory initializations.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8499 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c86
1 files changed, 43 insertions, 43 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 8673a3ab8..e14364b44 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -899,7 +899,7 @@ static int clif_set0078(struct block_list *bl, struct view_data *vd, unsigned ch
lv = status_get_lv(bl);
if(pcdb_checkid(vd->class_)) {
#if PACKETVER > 6
- memset(buf,0,packet_len_table[0x22a]);
+ malloc_set(buf,0,packet_len_table[0x22a]);
WBUFW(buf,0)=0x22a;
WBUFL(buf,2)=bl->id;
@@ -935,7 +935,7 @@ static int clif_set0078(struct block_list *bl, struct view_data *vd, unsigned ch
WBUFW(buf,56)=clif_setlevel(lv);
return packet_len_table[0x22a];
#elif PACKETVER > 3
- memset(buf,0,packet_len_table[0x1d8]);
+ malloc_set(buf,0,packet_len_table[0x1d8]);
WBUFW(buf,0)=0x1d8;
WBUFL(buf,2)=bl->id;
@@ -971,7 +971,7 @@ static int clif_set0078(struct block_list *bl, struct view_data *vd, unsigned ch
WBUFW(buf,52)=clif_setlevel(lv);
return packet_len_table[0x1d8];
#else
- memset(buf,0,packet_len_table[0x78]);
+ malloc_set(buf,0,packet_len_table[0x78]);
WBUFW(buf,0)=0x78;
WBUFL(buf,2)=bl->id;
@@ -1007,7 +1007,7 @@ static int clif_set0078(struct block_list *bl, struct view_data *vd, unsigned ch
#endif
}
//Non-player sprites need just a few fields filled.
- memset(buf,0,packet_len_table[0x78]);
+ malloc_set(buf,0,packet_len_table[0x78]);
WBUFW(buf,0)=0x78;
WBUFL(buf,2)=bl->id;
@@ -1056,7 +1056,7 @@ static int clif_set007b(struct block_list *bl, struct view_data *vd, struct unit
if(pcdb_checkid(vd->class_)) {
#if PACKETVER > 6
- memset(buf,0,packet_len_table[0x22c]);
+ malloc_set(buf,0,packet_len_table[0x22c]);
WBUFW(buf,0)=0x22c;
WBUFL(buf,2)=bl->id;
@@ -1093,7 +1093,7 @@ static int clif_set007b(struct block_list *bl, struct view_data *vd, struct unit
return packet_len_table[0x22c];
#elif PACKETVER > 3
- memset(buf,0,packet_len_table[0x1da]);
+ malloc_set(buf,0,packet_len_table[0x1da]);
WBUFW(buf,0)=0x1da;
WBUFL(buf,2)=bl->id;
@@ -1130,7 +1130,7 @@ static int clif_set007b(struct block_list *bl, struct view_data *vd, struct unit
return packet_len_table[0x1da];
#else
- memset(buf,0,packet_len_table[0x7b]);
+ malloc_set(buf,0,packet_len_table[0x7b]);
WBUFW(buf,0)=0x7b;
WBUFL(buf,2)=bl->id;
@@ -1168,7 +1168,7 @@ static int clif_set007b(struct block_list *bl, struct view_data *vd, struct unit
}
//Non-player sprites only require a few fields.
#if PACKETVER > 6
- memset(buf,0,packet_len_table[0x22c]);
+ malloc_set(buf,0,packet_len_table[0x22c]);
WBUFW(buf,0)=0x22c;
WBUFL(buf,2)=bl->id;
@@ -1193,7 +1193,7 @@ static int clif_set007b(struct block_list *bl, struct view_data *vd, struct unit
WBUFW(buf,62)=clif_setlevel(lv);
return packet_len_table[0x22c];
#else
- memset(buf,0,packet_len_table[0x7b]);
+ malloc_set(buf,0,packet_len_table[0x7b]);
WBUFW(buf,0)=0x7b;
WBUFL(buf,2)=bl->id;
@@ -1404,7 +1404,7 @@ int clif_spawn(struct block_list *bl)
}
} else { //Mob spawn packet.
struct status_change *sc = status_get_sc(bl);
- memset(buf,0,sizeof(buf));
+ malloc_tsetdword(buf,0,sizeof(buf));
WBUFW(buf,0)=0x7c;
WBUFL(buf,2)=bl->id;
WBUFW(buf,6)=status_get_speed(bl);
@@ -1463,7 +1463,7 @@ int clif_hominfo(struct map_session_data *sd, struct homun_data *hd, int flag)
nullpo_retr(0, hd);
status = &hd->battle_status;
- memset(buf,0,packet_len_table[0x22e]);
+ malloc_set(buf,0,packet_len_table[0x22e]);
WBUFW(buf,0)=0x22e;
memcpy(WBUFP(buf,2),sd->homunculus.name,NAME_LENGTH);
// WBUFB(buf,26)=sd->homunculus.rename_flag * 2;
@@ -1699,7 +1699,7 @@ int clif_movepc(struct map_session_data *sd) {
|| map[sd->bl.m].flag.rain
|| map[sd->bl.m].flag.clouds2
) {
- memset(buf,0,packet_len_table[0x7b]);
+ malloc_set(buf,0,packet_len_table[0x7b]);
WBUFW(buf,0)=0x7b;
WBUFL(buf,2)=-10;
WBUFW(buf,6)=sd->battle_status.speed;
@@ -2051,7 +2051,7 @@ void clif_sendfakenpc(struct map_session_data *sd, int npcid) {
int fd = sd->fd;
//sd->npc_id = npcid;
sd->state.using_fake_npc = 1;
- memset(WFIFOP(fd,0), 0, packet_len_table[0x78]);
+ malloc_set(WFIFOP(fd,0), 0, packet_len_table[0x78]);
WFIFOW(fd,0)=0x78;
WFIFOL(fd,2)=npcid;
WFIFOW(fd,14)=111;
@@ -3225,7 +3225,7 @@ int clif_misceffect2(struct block_list *bl, int type) {
nullpo_retr(0, bl);
- memset(buf, 0, packet_len_table[0x1f3]);
+ malloc_set(buf, 0, packet_len_table[0x1f3]);
WBUFW(buf,0) = 0x1f3;
WBUFL(buf,2) = bl->id;
@@ -4102,7 +4102,7 @@ int clif_getareachar_skillunit(struct map_session_data *sd,struct skill_unit *un
#if PACKETVER >= 3
if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris]
WFIFOHEAD(fd,packet_len_table[0x1c9]);
- memset(WFIFOP(fd,0),0,packet_len_table[0x1c9]);
+ malloc_set(WFIFOP(fd,0),0,packet_len_table[0x1c9]);
WFIFOW(fd, 0)=0x1c9;
WFIFOL(fd, 2)=unit->bl.id;
WFIFOL(fd, 6)=unit->group->src_id;
@@ -4117,7 +4117,7 @@ int clif_getareachar_skillunit(struct map_session_data *sd,struct skill_unit *un
}
#endif
WFIFOHEAD(fd,packet_len_table[0x11f]);
- memset(WFIFOP(fd,0),0,packet_len_table[0x11f]);
+ malloc_set(WFIFOP(fd,0),0,packet_len_table[0x11f]);
WFIFOW(fd, 0)=0x11f;
WFIFOL(fd, 2)=unit->bl.id;
WFIFOL(fd, 6)=unit->group->src_id;
@@ -4136,7 +4136,7 @@ int clif_getareachar_skillunit(struct map_session_data *sd,struct skill_unit *un
return 0;
/* Previous implementation guess of packet 0x1c9, who can understand what all those fields are for? [Skotlex]
WFIFOHEAD(fd,packet_len_table[0x1c9]);
- memset(WFIFOP(fd,0),0,packet_len_table[0x1c9]);
+ malloc_set(WFIFOP(fd,0),0,packet_len_table[0x1c9]);
WFIFOW(fd, 0)=0x1c9;
WFIFOL(fd, 2)=unit->bl.id;
WFIFOL(fd, 6)=unit->group->src_id;
@@ -4751,7 +4751,7 @@ int clif_skill_setunit(struct skill_unit *unit)
#if PACKETVER >= 3
if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris]
- memset(WBUFP(buf, 0),0,packet_len_table[0x1c9]);
+ malloc_set(WBUFP(buf, 0),0,packet_len_table[0x1c9]);
WBUFW(buf, 0)=0x1c9;
WBUFL(buf, 2)=unit->bl.id;
WBUFL(buf, 6)=unit->group->src_id;
@@ -4769,7 +4769,7 @@ int clif_skill_setunit(struct skill_unit *unit)
return 0;
}
#endif
- memset(WBUFP(buf, 0),0,packet_len_table[0x11f]);
+ malloc_set(WBUFP(buf, 0),0,packet_len_table[0x11f]);
WBUFW(buf, 0)=0x11f;
WBUFL(buf, 2)=unit->bl.id;
WBUFL(buf, 6)=unit->group->src_id;
@@ -4785,7 +4785,7 @@ int clif_skill_setunit(struct skill_unit *unit)
return 0;
/* Previous mysterious implementation noone really understands. [Skotlex]
- memset(WBUFP(buf, 0),0,packet_len_table[0x1c9]);
+ malloc_set(WBUFP(buf, 0),0,packet_len_table[0x1c9]);
WBUFW(buf, 0)=0x1c9;
WBUFL(buf, 2)=unit->bl.id;
WBUFL(buf, 6)=unit->group->src_id;
@@ -6389,7 +6389,7 @@ int clif_pet_emotion(struct pet_data *pd,int param)
nullpo_retr(0, pd);
- memset(buf,0,packet_len_table[0x1aa]);
+ malloc_set(buf,0,packet_len_table[0x1aa]);
WBUFW(buf,0)=0x1aa;
WBUFL(buf,2)=pd->bl.id;
@@ -6414,7 +6414,7 @@ int clif_pet_performance(struct block_list *bl,int param)
nullpo_retr(0, bl);
- memset(buf,0,packet_len_table[0x1a4]);
+ malloc_set(buf,0,packet_len_table[0x1a4]);
WBUFW(buf,0)=0x1a4;
WBUFB(buf,2)=4;
@@ -6432,7 +6432,7 @@ int clif_pet_equip(struct pet_data *pd)
nullpo_retr(0, pd);
- memset(buf,0,packet_len_table[0x1a4]);
+ malloc_set(buf,0,packet_len_table[0x1a4]);
WBUFW(buf,0)=0x1a4;
WBUFB(buf,2)=3;
@@ -6723,7 +6723,7 @@ int clif_guild_belonginfo(struct map_session_data *sd,struct guild *g)
ps=guild_getposition(sd,g);
WFIFOHEAD(fd,packet_len_table[0x16c]);
- memset(WFIFOP(fd,0),0,packet_len_table[0x16c]);
+ malloc_set(WFIFOP(fd,0),0,packet_len_table[0x16c]);
WFIFOW(fd,0)=0x16c;
WFIFOL(fd,2)=g->guild_id;
WFIFOL(fd,6)=g->emblem_id;
@@ -6930,7 +6930,7 @@ int clif_guild_memberlist(struct map_session_data *sd)
WFIFOL(fd,c*104+22)=m->exp;
WFIFOL(fd,c*104+26)=m->online;
WFIFOL(fd,c*104+30)=m->position;
- memset(WFIFOP(fd,c*104+34),0,50); // メモ?
+ malloc_tsetword(WFIFOP(fd,c*104+34),0,50); // メモ?
memcpy(WFIFOP(fd,c*104+84),m->name,NAME_LENGTH);
c++;
}
@@ -7084,7 +7084,7 @@ int clif_guild_skillinfo(struct map_session_data *sd)
WFIFOW(fd,c*37+12) = g->skill[i].lv;
WFIFOW(fd,c*37+14) = skill_get_sp(id,g->skill[i].lv);
WFIFOW(fd,c*37+16) = skill_get_range(id,g->skill[i].lv);
- memset(WFIFOP(fd,c*37+18),0,24);
+ malloc_tsetdword(WFIFOP(fd,c*37+18),0,24);
if(g->skill[i].lv < guild_skill_get_max(id) && (sd == g->member[0].sd))
up = 1;
else
@@ -7706,7 +7706,7 @@ void clif_soundeffect(struct map_session_data *sd,struct block_list *bl,char *na
int clif_soundeffectall(struct block_list *bl, char *name, int type, int coverage)
{
unsigned char buf[40];
- memset(buf, 0, packet_len_table[0x1d3]);
+ malloc_set(buf, 0, packet_len_table[0x1d3]);
if(coverage < 0 || coverage > 22){
ShowError("clif_soundeffectall: undefined coverage.\n");
@@ -7732,7 +7732,7 @@ int clif_specialeffect(struct block_list *bl, int type, int flag)
nullpo_retr(0, bl);
- memset(buf, 0, packet_len_table[0x1f3]);
+ malloc_set(buf, 0, packet_len_table[0x1f3]);
WBUFW(buf,0) = 0x1f3;
WBUFL(buf,2) = bl->id;
@@ -8035,7 +8035,7 @@ void clif_hate_mob(struct map_session_data *sd, int skilllv,int mob_id)
else if (mobdb_checkid(mob_id))
strncpy(WFIFOP(fd,2),mob_db(mob_id)->jname, NAME_LENGTH);
else //Really shouldn't happen...
- memset(WFIFOP(fd,2), 0, NAME_LENGTH);
+ malloc_tsetdword(WFIFOP(fd,2), 0, NAME_LENGTH);
WFIFOL(fd,26)=sd->bl.id;
WFIFOW(fd,30)=0xa00+skilllv-1;
WFIFOSET(fd, packet_len_table[0x20e]);
@@ -8519,7 +8519,7 @@ void check_fake_id(int fd, struct map_session_data *sd, int target_id) {
}
intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message_to_gm);
// send this info cause the bot ask until get an answer, damn spam
- memset(WPACKETP(0), 0, packet_len_table[0x95]);
+ malloc_tsetdword(WPACKETP(0), 0, packet_len_table[0x95]);
WPACKETW(0) = 0x95;
WPACKETL(2) = server_char_id;
strncpy(WPACKETP(6), sd->status.name, 24);
@@ -8560,7 +8560,7 @@ void check_fake_id(int fd, struct map_session_data *sd, int target_id) {
}
intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message_to_gm);
// send this info cause the bot ask until get an answer, damn spam
- memset(WPACKETP(0), 0, packet_len_table[0x95]);
+ malloc_tsetdword(WPACKETP(0), 0, packet_len_table[0x95]);
WPACKETW(0) = 0x95;
WPACKETL(2) = server_fake_mob_id;
fake_mob = fake_mob_list[(sd->bl.m + sd->fd + sd->status.char_id) % (sizeof(fake_mob_list) / sizeof(fake_mob_list[0]))]; // never same mob
@@ -10774,9 +10774,9 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd) {
*------------------------------------------
*/
void clif_parse_Shift(int fd, struct map_session_data *sd) { // Rewriten by [Yor]
- char player_name[NAME_LENGTH+1];
+ char player_name[NAME_LENGTH];
- memset(player_name, '\0', sizeof(player_name));
+ malloc_tsetdword(player_name, '\0', sizeof(player_name));
if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
(pc_isGM(sd) >= get_atcommand_level(AtCommand_JumpTo))) {
@@ -10793,9 +10793,9 @@ void clif_parse_Shift(int fd, struct map_session_data *sd) { // Rewriten by [Yor
*------------------------------------------
*/
void clif_parse_Recall(int fd, struct map_session_data *sd) { // Added by RoVeRT
- char player_name[25];
+ char player_name[NAME_LENGTH];
- memset(player_name, '\0', sizeof(player_name));
+ malloc_tsetdword(player_name, '\0', sizeof(player_name));
if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
(pc_isGM(sd) >= get_atcommand_level(AtCommand_Recall))) {
@@ -10815,7 +10815,7 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd) {
char monster_item_name[NAME_LENGTH+10]; //Additional space is for logging, eg: "@monster Poring"
int level;
- memset(monster_item_name, '\0', sizeof(monster_item_name));
+ malloc_tsetdword(monster_item_name, '\0', sizeof(monster_item_name));
if (battle_config.atc_gmonly == 0 || pc_isGM(sd)) {
RFIFOHEAD(fd);
@@ -10935,7 +10935,7 @@ void clif_parse_PMIgnore(int fd, struct map_session_data *sd) { // Rewritten by
int i, pos;
RFIFOHEAD(fd);
- memset(output, '\0', sizeof(output));
+ malloc_tsetdword(output, '\0', sizeof(output));
nick = (char*)RFIFOP(fd,2); // speed up
RFIFOB(fd,NAME_LENGTH+1) = '\0'; // to be sure that the player name have at maximum 23 characters (nick range: [2]->[26])
@@ -10996,7 +10996,7 @@ void clif_parse_PMIgnore(int fd, struct map_session_data *sd) { // Rewritten by
pos = -1;
for(i = 0; i < MAX_IGNORE_LIST; i++)
if (strcmp(sd->ignore[i].name, nick) == 0) {
- memset(sd->ignore[i].name, 0, sizeof(sd->ignore[i].name));
+ malloc_tsetdword(sd->ignore[i].name, 0, sizeof(sd->ignore[i].name));
if (pos == -1) {
WFIFOB(fd,3) = 0; // success
WFIFOSET(fd, packet_len_table[0x0d1]);
@@ -11313,7 +11313,7 @@ void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd) {
for(j = i + 1; j < MAX_FRIENDS; j++)
memcpy(&sd->status.friends[j-1], &sd->status.friends[j], sizeof(sd->status.friends[0]));
- memset(&sd->status.friends[MAX_FRIENDS-1], 0, sizeof(sd->status.friends[MAX_FRIENDS-1]));
+ malloc_set(&sd->status.friends[MAX_FRIENDS-1], 0, sizeof(sd->status.friends[MAX_FRIENDS-1]));
clif_displaymessage(fd, "Friend removed");
WFIFOHEAD(fd,packet_len_table[0x20a]);
@@ -12021,7 +12021,7 @@ static int packetdb_readdb(void)
}
}
- memset(str,0,sizeof(str));
+ malloc_tsetdword(str,0,sizeof(str));
for(j=0,p=line;j<4 && p;j++){
str[j]=p;
p=strchr(p,',');
@@ -12053,7 +12053,7 @@ static int packetdb_readdb(void)
for(i=0;i<MAX_PACKET_DB;i++){
if (packet_db[packet_ver][i].func == clif_parse_func[j].func)
{
- memset(&packet_db[packet_ver][i], 0, sizeof(struct packet_db));
+ malloc_tsetword(&packet_db[packet_ver][i], 0, sizeof(struct packet_db));
break;
}
}
@@ -12101,9 +12101,9 @@ static int packetdb_readdb(void)
int do_init_clif(void) {
clif_config.packet_db_ver = -1; // the main packet version of the DB
- memset(clif_config.connect_cmd, 0, sizeof(clif_config.connect_cmd)); //The default connect command will be determined after reading the packet_db [Skotlex]
+ malloc_tsetdword(clif_config.connect_cmd, 0, sizeof(clif_config.connect_cmd)); //The default connect command will be determined after reading the packet_db [Skotlex]
- memset(packet_db,0,sizeof(packet_db));
+ malloc_tsetword(packet_db,0,sizeof(packet_db));
//Using the packet_db file is the only way to set up packets now [Skotlex]
packetdb_readdb();