summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/graph.c2
-rw-r--r--src/common/grfio.c8
-rw-r--r--src/common/malloc.c86
-rw-r--r--src/common/malloc.h18
-rw-r--r--src/common/mapindex.c3
-rw-r--r--src/common/plugins.c2
-rw-r--r--src/common/socket.c10
-rw-r--r--src/common/socket.h2
-rw-r--r--src/common/strlib.c4
-rw-r--r--src/common/timer.c8
-rw-r--r--src/map/atcommand.c278
-rw-r--r--src/map/battle.c16
-rw-r--r--src/map/charcommand.c74
-rw-r--r--src/map/chrif.c8
-rw-r--r--src/map/clif.c86
-rw-r--r--src/map/guild.c10
-rw-r--r--src/map/irc.c54
-rw-r--r--src/map/itemdb.c14
-rw-r--r--src/map/log.c2
-rw-r--r--src/map/map.c6
-rw-r--r--src/map/mercenary.c6
-rw-r--r--src/map/mob.c42
-rw-r--r--src/map/npc.c18
-rw-r--r--src/map/party.c12
-rw-r--r--src/map/path.c3
-rw-r--r--src/map/pc.c40
-rw-r--r--src/map/pet.c12
-rw-r--r--src/map/script.c32
-rw-r--r--src/map/skill.c40
-rw-r--r--src/map/status.c40
-rw-r--r--src/map/storage.c4
-rw-r--r--src/map/trade.c15
-rw-r--r--src/map/unit.c2
33 files changed, 528 insertions, 429 deletions
diff --git a/src/common/graph.c b/src/common/graph.c
index 0a49fa709..4caa830e6 100644
--- a/src/common/graph.c
+++ b/src/common/graph.c
@@ -71,7 +71,7 @@ void graph_pallet(struct graph* g, int index,unsigned long c) {
if(g == NULL || c >= 256) return;
if(g->pallet_count <= index) {
- memset(g->png_data + 0x29 + 3 * g->pallet_count,0,(index - g->pallet_count) * 3);
+ malloc_set(g->png_data + 0x29 + 3 * g->pallet_count,0,(index - g->pallet_count) * 3);
g->pallet_count = index + 1;
}
g->png_data[0x29 + index * 3 ] = (unsigned char)((c >> 16) & 0xFF); // R
diff --git a/src/common/grfio.c b/src/common/grfio.c
index aa677a0e5..6cfc7eeaa 100644
--- a/src/common/grfio.c
+++ b/src/common/grfio.c
@@ -169,7 +169,7 @@ static void BitConvert(BYTE *Src,char *BitSwapTable)
int lop,prm;
BYTE tmp[8];
// *(DWORD*)tmp=*(DWORD*)(tmp+4)=0;
- memset(tmp,0,8);
+ malloc_tsetdword(tmp,0,8);
for(lop=0;lop!=64;lop++) {
prm = BitSwapTable[lop]-1;
if (Src[(prm >> 3) & 7] & BitMaskTable[prm & 7]) {
@@ -299,7 +299,7 @@ int decode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char*
int encode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen) {
z_stream stream;
int err;
- memset(&stream, 0, sizeof(stream));
+ malloc_tsetdword(&stream, 0, sizeof(stream));
stream.next_in = (Bytef*)source;
stream.avail_in = (uInt)sourceLen;
/* Check for source > 64K on 16-bit machine: */
@@ -479,7 +479,7 @@ static FILELIST* filelist_add(FILELIST *entry)
if (filelist_entrys >= filelist_maxentry) {
filelist = (FILELIST *)aRealloc(filelist, (filelist_maxentry + FILELIST_ADDS) * sizeof(FILELIST));
- memset(filelist + filelist_maxentry, '\0', FILELIST_ADDS * sizeof(FILELIST));
+ malloc_tsetdword(filelist + filelist_maxentry, '\0', FILELIST_ADDS * sizeof(FILELIST));
filelist_maxentry += FILELIST_ADDS;
}
@@ -949,7 +949,7 @@ char *grfio_alloc_ptr(char *fname)
if (gentry_entrys >= gentry_maxentry) {
gentry_maxentry += GENTRY_ADDS;
gentry_table = (char**)aRealloc(gentry_table, gentry_maxentry * sizeof(char*));
- memset(gentry_table + (gentry_maxentry - GENTRY_ADDS), 0, sizeof(char*) * GENTRY_ADDS);
+ malloc_tsetdword(gentry_table + (gentry_maxentry - GENTRY_ADDS), 0, sizeof(char*) * GENTRY_ADDS);
}
len = strlen( fname );
buf = (char*)aMallocA(len + 1);
diff --git a/src/common/malloc.c b/src/common/malloc.c
index 6eaa994d8..700da0f88 100644
--- a/src/common/malloc.c
+++ b/src/common/malloc.c
@@ -4,7 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "malloc.h"
+#include "../common/malloc.h"
#include "../common/core.h"
#include "../common/showmsg.h"
@@ -116,13 +116,15 @@ void aFree_ (void *p, const char *file, int line, const char *func)
void* _bcallocA(size_t size, size_t cnt)
{
void *ret = MALLOCA(size * cnt);
- if (ret) memset(ret, 0, size * cnt);
+ if (ret) //memset(ret, 0, size * cnt);
+ malloc_set(ret, 0, size*cnt);
return ret;
}
void* _bcalloc(size_t size, size_t cnt)
{
void *ret = MALLOC(size * cnt);
- if (ret) memset(ret, 0, size * cnt);
+ if (ret) //memset(ret, 0, size * cnt);
+ malloc_set(ret, 0, size*cnt);
return ret;
}
char* _bstrdup(const char *chr)
@@ -325,7 +327,8 @@ void* _mmalloc(size_t size, const char *file, int line, const char *func ) {
void* _mcalloc(size_t num, size_t size, const char *file, int line, const char *func ) {
void *p = _mmalloc(num * size,file,line,func);
- memset(p,0,num * size);
+ //memset(p,0,num * size);
+ malloc_set(p,0,num*size);
return p;
}
@@ -683,6 +686,81 @@ static void memmgr_init (void)
}
#endif
+#ifdef MEMSET_TURBO
+ // This function is practically useless if the the size of the data is
+ // static. It decides whether to use setword or setdword.
+ void malloc_set(void *dest, int value, int size)
+ {
+ if(size%4 == 0)
+ malloc_tsetdword(dest, value, size);
+ else if(size%2 == 0)
+ malloc_tsetword(dest, (short)value, size);
+ else
+ memset(dest, value, (size_t) size);
+ }
+
+ // Sets 32-bit aligned memory.
+ void malloc_tsetdword(void *dest, int value, int count){
+#ifdef _WIN32
+ _asm
+ {
+ mov edx, 0
+ mov eax, count
+ mov ebx, 4
+ idiv ebx
+ mov edi, dest
+ mov ecx, eax
+ mov eax, value
+ rep stosd
+ }
+#else
+ __asm__("movl $0, %%edx;
+ movl %1, %%eax;
+ movl $4, %%ebx;
+ idivl %%ebx;
+ movl %0, %%edi;
+ movl %%eax, %%ecx;
+ movl %2, %%eax;
+ rep;
+ stosd;"
+ :
+ : "g" (dest), "g" (count), "g" (value)
+ : "edx", "eax", "ebx", "edi", "ecx"
+ );
+#endif
+ }
+
+ // Sets 16-bit aligned memory.
+ void malloc_tsetword(void *dest, short value, int count){
+#ifdef _WIN32
+ _asm
+ {
+ mov edx, 0
+ mov eax, count
+ mov ebx, 2
+ idiv ebx
+ mov edi, dest
+ mov ecx, eax
+ mov ax, value
+ rep stosw
+ }
+#else
+ __asm__("movl $0, %%edx;
+ movl %1, %%eax;
+ movl $2, %%ebx;
+ idivl %%ebx;
+ movl %0, %%edi;
+ movl %%eax, %%ecx;
+ movw %2, %%ax;
+ rep;
+ stosw;"
+ :
+ : "g" (dest), "g" (count), "g" (value)
+ : "edx", "eax", "ebx", "edi", "ecx", "ax"
+ );
+#endif
+ }
+#endif
/*======================================
* Initialise
diff --git a/src/common/malloc.h b/src/common/malloc.h
index e9dbb9d44..d3df667a6 100644
--- a/src/common/malloc.h
+++ b/src/common/malloc.h
@@ -4,6 +4,8 @@
#ifndef _MALLOC_H_
#define _MALLOC_H_
+//#define MEMSET_TURBO
+
#ifndef __NETBSD__
#if __STDC_VERSION__ < 199901L
# if __GNUC__ >= 2
@@ -147,6 +149,22 @@
////////////////////////////////////////////////
unsigned int malloc_usage (void);
+#ifndef INLINE
+ #ifdef _WIN32
+ #define INLINE
+ #else
+ #define INLINE inline
+ #endif
+#endif
+#ifdef MEMSET_TURBO
+ INLINE void malloc_tsetdword(void *dest, int value, int count);
+ INLINE void malloc_tsetword(void *dest, short value, int count);
+ INLINE void malloc_set(void *dest, int value, int size);
+#else
+ #define malloc_tsetdword(x,y,z) memset(x,y,z)
+ #define malloc_tsetword(x,y,z) memset(x,y,z)
+ #define malloc_set(x,y,z) memset(x,y,z)
+#endif
void malloc_init (void);
void malloc_final (void);
diff --git a/src/common/mapindex.c b/src/common/mapindex.c
index 8fbf2da12..0c3faec75 100644
--- a/src/common/mapindex.c
+++ b/src/common/mapindex.c
@@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "showmsg.h"
+#include "../common/malloc.h"
#define MAX_MAPINDEX 2000
@@ -70,7 +71,7 @@ void mapindex_init(void) {
int index, length;
char map_name[1024];
- memset (&indexes, 0, sizeof (indexes));
+ malloc_tsetdword (&indexes, 0, sizeof (indexes));
fp=fopen(mapindex_cfgfile,"r");
if(fp==NULL){
ShowFatalError("Unable to read mapindex config file %s!\n", mapindex_cfgfile);
diff --git a/src/common/plugins.c b/src/common/plugins.c
index fbadca065..a057190b9 100644
--- a/src/common/plugins.c
+++ b/src/common/plugins.c
@@ -133,7 +133,7 @@ int export_symbol (void *var, int offset)
plugin_call_table = (void**)aRealloc(plugin_call_table, max_call_table*sizeof(void*));
// clear the new alloced block
- memset(plugin_call_table + call_table_size, 0, (max_call_table-call_table_size)*sizeof(void*));
+ malloc_tsetdword(plugin_call_table + call_table_size, 0, (max_call_table-call_table_size)*sizeof(void*));
}
// the new table size is delimited by the new element at the end
diff --git a/src/common/socket.c b/src/common/socket.c
index dc8162ee1..3d7684972 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -424,7 +424,7 @@ int make_listen_port(int port)
CREATE(session[fd], struct socket_data, 1);
- memset(session[fd],0,sizeof(*session[fd]));
+ malloc_set(session[fd],0,sizeof(*session[fd]));
session[fd]->func_recv = connect_client;
return fd;
@@ -502,7 +502,7 @@ int make_listen_bind(long ip,int port)
CREATE(session[fd], struct socket_data, 1);
- memset(session[fd],0,sizeof(*session[fd]));
+ malloc_set(session[fd],0,sizeof(*session[fd]));
session[fd]->func_recv = connect_client;
ShowStatus("Open listen port on %d.%d.%d.%d:%i\n",
@@ -517,7 +517,7 @@ int console_recieve(int i) {
char *buf;
CREATE_A(buf, char, 64);
- memset(buf,0,sizeof(64));
+ malloc_tsetdword(buf,0,sizeof(64));
n = read(0, buf , 64);
if ( n < 0 )
@@ -580,7 +580,7 @@ int start_console(void) {
if (!session[0]) { // dummy socket already uses fd 0
CREATE(session[0], struct socket_data, 1);
}
- memset(session[0],0,sizeof(*session[0]));
+ malloc_set(session[0],0,sizeof(*session[0]));
session[0]->func_recv = console_recieve;
session[0]->func_console = default_console_parse;
@@ -1369,7 +1369,7 @@ void socket_init (void)
session[0]->max_rdata = (int)2*rfifo_size;
session[0]->max_wdata = (int)2*wfifo_size;
- memset (func_parse_table, 0, sizeof(func_parse_table));
+ malloc_set (func_parse_table, 0, sizeof(func_parse_table));
func_parse_table[SESSION_RAW].check = default_func_check;
func_parse_table[SESSION_RAW].func = default_func_parse;
diff --git a/src/common/socket.h b/src/common/socket.h
index 158759f9e..ca4b20c91 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -16,7 +16,7 @@ typedef long in_addr_t;
#include <netinet/in.h>
#endif
#include <time.h>
-#include "malloc.h"
+#include "../common/malloc.h"
#include "cbasetypes.h"
extern time_t last_tick;
diff --git a/src/common/strlib.c b/src/common/strlib.c
index d62bf4f46..8cff2a878 100644
--- a/src/common/strlib.c
+++ b/src/common/strlib.c
@@ -8,7 +8,7 @@
#include "strlib.h"
#include "utils.h"
-#include "malloc.h"
+#include "../common/malloc.h"
//-----------------------------------------------
// string lib.
@@ -123,7 +123,7 @@ char *trim(char *str, const char *delim)
char *strp = strtok(str,delim);
char buf[1024];
char *bufp = buf;
- memset(buf,0,sizeof buf);
+ malloc_tsetdword(buf,0,sizeof buf);
while(strp) {
strcpy(bufp, strp);
diff --git a/src/common/timer.c b/src/common/timer.c
index 9baa33e08..1e9ff25aa 100644
--- a/src/common/timer.c
+++ b/src/common/timer.c
@@ -20,7 +20,7 @@
#include <time.h>
#include "timer.h"
-#include "malloc.h"
+#include "../common/malloc.h"
#include "showmsg.h"
// タイマー間隔の最小値。モンスターの大量召還時、多数のクライアント接続時に
@@ -137,7 +137,7 @@ static void push_timer_heap(int index)
} else {
timer_heap_max += 256;
timer_heap = (int *) aRealloc( timer_heap, sizeof(int) * timer_heap_max);
- memset(timer_heap + (timer_heap_max - 256), 0, sizeof(int) * 256);
+ malloc_tsetdword(timer_heap + (timer_heap_max - 256), 0, sizeof(int) * 256);
}
}
@@ -210,7 +210,7 @@ int acquire_timer (void)
} else {
timer_data_max += 256;
timer_data = (struct TimerData *) aRealloc( timer_data, sizeof(struct TimerData) * timer_data_max);
- memset(timer_data + (timer_data_max - 256), 0, sizeof(struct TimerData) * 256);
+ malloc_tsetdword(timer_data + (timer_data_max - 256), 0, sizeof(struct TimerData) * 256);
}
}
@@ -383,7 +383,7 @@ int do_timer(unsigned int tick)
if (free_timer_list_pos >= free_timer_list_max) {
free_timer_list_max += 256;
free_timer_list = (int *) aRealloc(free_timer_list, sizeof(int) * free_timer_list_max);
- memset(free_timer_list + (free_timer_list_max - 256), 0, 256 * sizeof(int));
+ malloc_tsetdword(free_timer_list + (free_timer_list_max - 256), 0, 256 * sizeof(int));
}
free_timer_list[free_timer_list_pos++] = i;
break;
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index c4da0af2f..62fe834c8 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -795,7 +795,7 @@ is_atcommand(const int fd, struct map_session_data* sd, const char* message, int
if (!message || !*message)
return AtCommand_None;
- memset(&info, 0, sizeof(info));
+ malloc_set(&info, 0, sizeof(info));
str += strlen(sd->status.name);
while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
if (*str == ':')
@@ -816,8 +816,8 @@ is_atcommand(const int fd, struct map_session_data* sd, const char* message, int
if (type != AtCommand_None) {
char command[100];
const char* p = str;
- memset(command, '\0', sizeof(command));
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(command, '\0', sizeof(command));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
while (*p && !isspace(*p))
p++;
if (p - str >= sizeof(command)) // too long
@@ -862,7 +862,7 @@ AtCommandType atcommand(struct map_session_data* sd, const int level, const char
if (*p == command_symbol) { // check first char.
char command[101];
int i = 0;
- memset(info, 0, sizeof(AtCommandInfo));
+ malloc_set(info, 0, sizeof(AtCommandInfo));
sscanf(p, "%100s", command);
command[sizeof(command)-1] = '\0';
@@ -907,7 +907,7 @@ int msg_config_read(const char *cfgName) {
}
if ((--called) == 0)
- memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
+ malloc_tsetdword(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
while(fgets(line, sizeof(line)-1, fp)) {
if (line[0] == '/' && line[1] == '/')
continue;
@@ -1190,7 +1190,7 @@ int atcommand_commands(
int i_cur_cmd,gm_lvl = pc_isGM(sd), count = 0;
- memset(cz_line_buff,' ',MESSAGE_SIZE);
+ malloc_tsetdword(cz_line_buff,' ',MESSAGE_SIZE);
cz_line_buff[MESSAGE_SIZE] = 0;
clif_displaymessage(fd, msg_txt(273));
@@ -1208,7 +1208,7 @@ int atcommand_commands(
{
clif_displaymessage(fd,(char*)cz_line_buff);
lpcz_cur = cz_line_buff;
- memset(cz_line_buff,' ',MESSAGE_SIZE);
+ malloc_tsetdword(cz_line_buff,' ',MESSAGE_SIZE);
cz_line_buff[MESSAGE_SIZE] = 0;
}
@@ -1291,7 +1291,7 @@ int atcommand_rura(
nullpo_retr(-1, sd);
- memset(map_name, '\0', sizeof(map_name));
+ malloc_tsetdword(map_name, '\0', sizeof(map_name));
if (!message || !*message ||
(sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
@@ -1347,7 +1347,7 @@ int atcommand_where(
int GM_level, pl_GM_level;
nullpo_retr(-1, sd);
- memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
@@ -1396,7 +1396,7 @@ int atcommand_jumpto(
return -1;
}
- memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
return -1;
if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) //Yourself mate? Tsk tsk tsk.
@@ -1434,7 +1434,7 @@ int atcommand_jump(
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
sscanf(message, "%d %d", &x, &y);
@@ -1469,9 +1469,9 @@ int atcommand_who3(
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
- memset(match_text, '\0', sizeof(match_text));
- memset(player_name, '\0', sizeof(player_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(match_text, '\0', sizeof(match_text));
+ malloc_tsetdword(player_name, '\0', sizeof(player_name));
if (sscanf(message, "%99[^\n]", match_text) < 1)
strcpy(match_text, "");
@@ -1544,9 +1544,9 @@ int atcommand_who2(
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
- memset(match_text, '\0', sizeof(match_text));
- memset(player_name, '\0', sizeof(player_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(match_text, '\0', sizeof(match_text));
+ malloc_tsetdword(player_name, '\0', sizeof(player_name));
if (sscanf(message, "%99[^\n]", match_text) < 1)
strcpy(match_text, "");
@@ -1616,10 +1616,10 @@ int atcommand_who(
nullpo_retr(-1, sd);
- memset(temp0, '\0', sizeof(temp0));
- memset(atcmd_output, '\0', sizeof(atcmd_output));
- memset(match_text, '\0', sizeof(match_text));
- memset(player_name, '\0', sizeof(player_name));
+ malloc_tsetdword(temp0, '\0', sizeof(temp0));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(match_text, '\0', sizeof(match_text));
+ malloc_tsetdword(player_name, '\0', sizeof(player_name));
if (sscanf(message, "%99[^\n]", match_text) < 1)
strcpy(match_text, "");
@@ -1693,8 +1693,8 @@ int atcommand_whomap3(
int map_id;
char map_name[MAP_NAME_LENGTH];
- memset(atcmd_output, '\0', sizeof(atcmd_output));
- memset(map_name, '\0', sizeof(map_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(map_name, '\0', sizeof(map_name));
if (!message || !*message)
map_id = sd->bl.m;
@@ -1753,8 +1753,8 @@ int atcommand_whomap2(
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
- memset(map_name, '\0', sizeof(map_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(map_name, '\0', sizeof(map_name));
if (!message || !*message)
map_id = sd->bl.m;
@@ -1817,10 +1817,10 @@ int atcommand_whomap(
nullpo_retr(-1, sd);
- memset(temp0, '\0', sizeof(temp0));
- memset(temp1, '\0', sizeof(temp1));
- memset(atcmd_output, '\0', sizeof(atcmd_output));
- memset(map_name, '\0', sizeof(map_name));
+ malloc_tsetdword(temp0, '\0', sizeof(temp0));
+ malloc_tsetdword(temp1, '\0', sizeof(temp1));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(map_name, '\0', sizeof(map_name));
if (!message || !*message)
map_id = sd->bl.m;
@@ -1894,11 +1894,11 @@ int atcommand_whogm(
nullpo_retr(-1, sd);
- memset(temp0, '\0', sizeof(temp0));
- memset(temp1, '\0', sizeof(temp1));
- memset(atcmd_output, '\0', sizeof(atcmd_output));
- memset(match_text, '\0', sizeof(match_text));
- memset(player_name, '\0', sizeof(player_name));
+ malloc_tsetdword(temp0, '\0', sizeof(temp0));
+ malloc_tsetdword(temp1, '\0', sizeof(temp1));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(match_text, '\0', sizeof(match_text));
+ malloc_tsetdword(player_name, '\0', sizeof(player_name));
if (sscanf(message, "%99[^\n]", match_text) < 1)
strcpy(match_text, "");
@@ -1965,9 +1965,9 @@ int atcommand_whozeny(
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
- memset(match_text, '\0', sizeof(match_text));
- memset(player_name, '\0', sizeof(player_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(match_text, '\0', sizeof(match_text));
+ malloc_tsetdword(player_name, '\0', sizeof(player_name));
if (sscanf(message, "%99[^\n]", match_text) < 1)
strcpy(match_text, "");
@@ -2115,7 +2115,7 @@ int atcommand_speed(
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message) {
sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
@@ -2150,8 +2150,8 @@ int atcommand_charspeed(
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || !*message || sscanf(message, "%d %23[^\n]", &speed, atcmd_player_name) < 2) {
sprintf(atcmd_output, "Please, enter a speed and a player name (usage: @charspeed <speed <%d-%d>> <char name>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
@@ -2453,7 +2453,7 @@ int atcommand_kill(
struct map_session_data *pl_sd;
nullpo_retr(-1, sd);
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
@@ -2504,7 +2504,7 @@ int atcommand_kami(
unsigned long color=0;
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if(*(command + 5) != 'c' && *(command + 5) != 'C') {
@@ -2605,7 +2605,7 @@ int atcommand_item(
int get_count, i;
nullpo_retr(-1, sd);
- memset(item_name, '\0', sizeof(item_name));
+ malloc_tsetdword(item_name, '\0', sizeof(item_name));
if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
@@ -2631,7 +2631,7 @@ int atcommand_item(
for (i = 0; i < number; i += get_count) {
// if not pet egg
if (!pet_create_egg(sd, item_id)) {
- memset(&item_tmp, 0, sizeof(item_tmp));
+ malloc_set(&item_tmp, 0, sizeof(item_tmp));
item_tmp.nameid = item_id;
item_tmp.identify = 1;
@@ -2666,7 +2666,7 @@ int atcommand_item2(
int loop, get_count, i;
nullpo_retr(-1, sd);
- memset(item_name, '\0', sizeof(item_name));
+ malloc_tsetdword(item_name, '\0', sizeof(item_name));
if (!message || !*message || sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9) {
clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
@@ -2702,7 +2702,7 @@ int atcommand_item2(
refine = attr = 0;
}
for (i = 0; i < loop; i++) {
- memset(&item_tmp, 0, sizeof(item_tmp));
+ malloc_set(&item_tmp, 0, sizeof(item_tmp));
item_tmp.nameid = item_id;
item_tmp.identify = identify;
item_tmp.refine = refine;
@@ -2895,7 +2895,7 @@ int atcommand_help(
FILE* fp;
nullpo_retr(-1, sd);
- memset(buf, '\0', sizeof(buf));
+ malloc_tsetdword(buf, '\0', sizeof(buf));
if ((fp = fopen(help_txt, "r")) != NULL) {
clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
@@ -2936,7 +2936,7 @@ int atcommand_help2(
FILE* fp;
nullpo_retr(-1, sd);
- memset(buf, '\0', sizeof(buf));
+ malloc_tsetdword(buf, '\0', sizeof(buf));
if ((fp = fopen(help2_txt, "r")) != NULL) {
clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
@@ -2976,7 +2976,7 @@ int atcommand_gm(
char password[100];
nullpo_retr(-1, sd);
- memset(password, '\0', sizeof(password));
+ malloc_tsetdword(password, '\0', sizeof(password));
if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
@@ -3125,7 +3125,7 @@ int atcommand_model(
int hair_style = 0, hair_color = 0, cloth_color = 0;
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
@@ -3168,7 +3168,7 @@ int atcommand_dye(const int fd, struct map_session_data* sd, const char* command
int cloth_color = 0;
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
@@ -3196,7 +3196,7 @@ int atcommand_hair_style(const int fd, struct map_session_data* sd, const char*
int hair_style = 0;
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
@@ -3243,7 +3243,7 @@ int atcommand_hair_color(const int fd, struct map_session_data* sd, const char*
int hair_color = 0;
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
@@ -3315,8 +3315,8 @@ int atcommand_go(
return 0;
}
- memset(map_name, '\0', sizeof(map_name));
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(map_name, '\0', sizeof(map_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
// get the number
town = atoi(message);
@@ -3469,9 +3469,9 @@ int atcommand_monster(
short mx, my;
nullpo_retr(-1, sd);
- memset(name, '\0', sizeof(name));
- memset(monster, '\0', sizeof(monster));
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(name, '\0', sizeof(name));
+ malloc_tsetdword(monster, '\0', sizeof(monster));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message) {
clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
@@ -3728,7 +3728,7 @@ void atcommand_killmonster_sub(
if (!sd) return;
- memset(map_name, '\0', sizeof(map_name));
+ malloc_tsetdword(map_name, '\0', sizeof(map_name));
if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
map_id = sd->bl.m;
@@ -3786,7 +3786,7 @@ int atcommand_refine(
int count;
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
@@ -3859,8 +3859,8 @@ int atcommand_produce(
struct item tmp_item;
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
- memset(item_name, '\0', sizeof(item_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(item_name, '\0', sizeof(item_name));
if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
@@ -3881,7 +3881,7 @@ int atcommand_produce(
attribute = ATTRIBUTE_NORMAL;
if (star < MIN_STAR || star > MAX_STAR)
star = 0;
- memset(&tmp_item, 0, sizeof tmp_item);
+ malloc_set(&tmp_item, 0, sizeof tmp_item);
tmp_item.nameid = item_id;
tmp_item.amount = 1;
tmp_item.identify = 1;
@@ -3917,7 +3917,7 @@ void atcommand_memo_sub(struct map_session_data* sd) {
if (!sd) return;
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
@@ -3942,7 +3942,7 @@ int atcommand_memo(
int position = 0;
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d", &position) < 1)
atcommand_memo_sub(sd);
@@ -3985,7 +3985,7 @@ int atcommand_gat(
int y;
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
for (y = 2; y >= -2; y--) {
sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
@@ -4215,7 +4215,7 @@ int atcommand_param(
status[4] = &sd->status.dex;
status[5] = &sd->status.luk;
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
@@ -4543,7 +4543,7 @@ atcommand_recall(
return -1;
}
- memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
if(sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
return -1;
if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
@@ -4585,7 +4585,7 @@ int atcommand_revive(
struct map_session_data *pl_sd;
nullpo_retr(-1, sd);
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
@@ -4618,7 +4618,7 @@ int atcommand_char_block(
{
nullpo_retr(-1, sd);
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
@@ -4664,8 +4664,8 @@ int atcommand_char_ban(
int year, month, day, hour, minute, second, value;
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || !*message || sscanf(message, "%s %99[^\n]", atcmd_output, atcmd_player_name) < 2) {
clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
@@ -4738,7 +4738,7 @@ int atcommand_char_unblock(
{
nullpo_retr(-1, sd);
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
@@ -4771,7 +4771,7 @@ int atcommand_char_unban(
{
nullpo_retr(-1, sd);
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
@@ -4958,7 +4958,7 @@ int atcommand_kick(
struct map_session_data *pl_sd;
nullpo_retr(-1, sd);
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
@@ -5151,7 +5151,7 @@ int atcommand_party(
char party[NAME_LENGTH];
nullpo_retr(-1, sd);
- memset(party, '\0', sizeof(party));
+ malloc_tsetdword(party, '\0', sizeof(party));
if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
@@ -5175,7 +5175,7 @@ int atcommand_guild(
int prev;
nullpo_retr(-1, sd);
- memset(guild, '\0', sizeof(guild));
+ malloc_tsetdword(guild, '\0', sizeof(guild));
if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
@@ -5271,8 +5271,8 @@ int atcommand_idsearch(
struct item_data *item_array[MAX_SEARCH];
nullpo_retr(-1, sd);
- memset(item_name, '\0', sizeof(item_name));
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(item_name, '\0', sizeof(item_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
@@ -5310,7 +5310,7 @@ int atcommand_recallall(
int count, users;
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
@@ -5357,8 +5357,8 @@ int atcommand_guildrecall(
struct guild *g;
nullpo_retr(-1, sd);
- memset(guild_name, '\0', sizeof(guild_name));
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(guild_name, '\0', sizeof(guild_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
@@ -5414,8 +5414,8 @@ int atcommand_partyrecall(
int count, users;
nullpo_retr(-1, sd);
- memset(party_name, '\0', sizeof(party_name));
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(party_name, '\0', sizeof(party_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
@@ -5644,9 +5644,9 @@ int atcommand_mapinfo(
unsigned short m_index;
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- memset(direction, '\0', sizeof(direction));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(direction, '\0', sizeof(direction));
sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
@@ -5887,7 +5887,7 @@ int atcommand_char_mount_peco(
struct map_session_data *pl_sd;
nullpo_retr(-1, sd);
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
@@ -5928,8 +5928,8 @@ int atcommand_guildspy(
struct guild *g;
nullpo_retr(-1, sd);
- memset(guild_name, '\0', sizeof(guild_name));
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(guild_name, '\0', sizeof(guild_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!enable_spy)
{
@@ -5972,8 +5972,8 @@ int atcommand_partyspy(
struct party_data *p;
nullpo_retr(-1, sd);
- memset(party_name, '\0', sizeof(party_name));
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(party_name, '\0', sizeof(party_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!enable_spy)
{
@@ -6045,7 +6045,7 @@ int atcommand_nuke(
struct map_session_data *pl_sd;
nullpo_retr(-1, sd);
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
@@ -6081,7 +6081,7 @@ int atcommand_tonpc(const int fd, struct map_session_data* sd,
nullpo_retr(-1, sd);
- memset(npcname, 0, sizeof(npcname));
+ malloc_tsetdword(npcname, 0, sizeof(npcname));
if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
@@ -6111,7 +6111,7 @@ int atcommand_shownpc(const int fd, struct map_session_data* sd,
char NPCname[NAME_LENGTH];
nullpo_retr(-1, sd);
- memset(NPCname, '\0', sizeof(NPCname));
+ malloc_tsetdword(NPCname, '\0', sizeof(NPCname));
if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
@@ -6139,7 +6139,7 @@ int atcommand_hidenpc(const int fd, struct map_session_data* sd,
char NPCname[NAME_LENGTH];
nullpo_retr(-1, sd);
- memset(NPCname, '\0', sizeof(NPCname));
+ malloc_tsetdword(NPCname, '\0', sizeof(NPCname));
if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
@@ -6190,7 +6190,7 @@ int atcommand_unloadnpc(const int fd, struct map_session_data* sd,
char NPCname[NAME_LENGTH];
nullpo_retr(-1, sd);
- memset(NPCname, '\0', sizeof(NPCname));
+ malloc_tsetdword(NPCname, '\0', sizeof(NPCname));
if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
@@ -6217,8 +6217,8 @@ char * txt_time(unsigned int duration) {
char temp[256];
static char temp1[256];
- memset(temp, '\0', sizeof(temp));
- memset(temp1, '\0', sizeof(temp1));
+ malloc_tsetdword(temp, '\0', sizeof(temp));
+ malloc_tsetdword(temp1, '\0', sizeof(temp1));
days = duration / (60 * 60 * 24);
duration = duration - (60 * 60 * 24 * days);
@@ -6262,7 +6262,7 @@ int atcommand_servertime(const int fd, struct map_session_data* sd,
char temp[256];
nullpo_retr(-1, sd);
- memset(temp, '\0', sizeof(temp));
+ malloc_tsetdword(temp, '\0', sizeof(temp));
time(&time_server); // get time in seconds since 1/1/1970
datetime = localtime(&time_server); // convert seconds in structure
@@ -6338,9 +6338,9 @@ int atcommand_chardelitem(const int fd, struct map_session_data* sd,
struct item_data *item_data;
nullpo_retr(-1, sd);
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- memset(item_name, '\0', sizeof(item_name));
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(item_name, '\0', sizeof(item_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 || number < 1) {
clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
@@ -6436,7 +6436,7 @@ int atcommand_jail(
unsigned short m_index;
nullpo_retr(-1, sd);
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
@@ -6496,7 +6496,7 @@ int atcommand_unjail(
unsigned short m_index;
int x=0, y=0;
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
@@ -6849,7 +6849,7 @@ int atcommand_exp(
char output[200];
double nextb, nextj;
nullpo_retr(-1, sd);
- memset(output, '\0', sizeof(output));
+ malloc_tsetdword(output, '\0', sizeof(output));
nextb = pc_nextbaseexp(sd);
if (nextb)
@@ -6875,7 +6875,7 @@ int atcommand_broadcast(
{
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message) {
clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
@@ -6898,7 +6898,7 @@ int atcommand_localbroadcast(
{
nullpo_retr(-1, sd);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message) {
clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
@@ -6925,8 +6925,8 @@ int atcommand_chardisguise(
struct map_session_data* pl_sd;
nullpo_retr(-1, sd);
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- memset(mob_name, '\0', sizeof(mob_name));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(mob_name, '\0', sizeof(mob_name));
if (!message || !*message || sscanf(message, "%s %23[^\n]", mob_name, atcmd_player_name) < 2) {
clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
@@ -6979,7 +6979,7 @@ int atcommand_charundisguise(
struct map_session_data* pl_sd;
nullpo_retr(-1, sd);
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
@@ -7018,8 +7018,8 @@ int atcommand_email(
char new_email[100];
nullpo_retr(-1, sd);
- memset(actual_email, '\0', sizeof(actual_email));
- memset(new_email, '\0', sizeof(new_email));
+ malloc_tsetdword(actual_email, '\0', sizeof(actual_email));
+ malloc_tsetdword(new_email, '\0', sizeof(new_email));
if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
@@ -7083,9 +7083,9 @@ atcommand_character_cart_list(
int i, j, count, counter, counter2;
nullpo_retr(-1, sd);
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- memset(atcmd_output, '\0', sizeof(atcmd_output));
- memset(outputtmp, '\0', sizeof(outputtmp));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(outputtmp, '\0', sizeof(outputtmp));
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
@@ -7109,7 +7109,7 @@ atcommand_character_cart_list(
else
sprintf(atcmd_output, "%d %s (%s, id: %d)", pl_sd->status.cart[i].amount, item_data->name, item_data->jname, pl_sd->status.cart[i].nameid);
clif_displaymessage(fd, atcmd_output);
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
counter2 = 0;
for (j = 0; j < item_data->slot; j++) {
if (pl_sd->status.cart[i].card[j]) {
@@ -7269,7 +7269,7 @@ atcommand_npcmove(const int fd, struct map_session_data* sd,
if (!message || !*message)
return -1;
- memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
if (sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
@@ -7658,7 +7658,7 @@ void getring (struct map_session_data *sd)
else
item_id = 2634;
- memset(&item_tmp,0,sizeof(item_tmp));
+ malloc_set(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid=item_id;
item_tmp.identify=1;
item_tmp.card[0]=255;
@@ -8333,7 +8333,7 @@ atcommand_sound(
return -1;
}
- memset(sound_file, '\0', sizeof(sound_file));
+ malloc_tsetdword(sound_file, '\0', sizeof(sound_file));
if(sscanf(message, "%99[^\n]", sound_file) < 1)
return -1;
@@ -8979,8 +8979,8 @@ int atcommand_jumptoid(
int session_id=0;
struct map_session_data *pl_sd;
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
@@ -9032,8 +9032,8 @@ int atcommand_jumptoid2(
int session_id=0;
struct map_session_data *pl_sd;
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
@@ -9084,8 +9084,8 @@ int atcommand_recallid(
int session_id=0;
struct map_session_data *pl_sd;
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
@@ -9141,8 +9141,8 @@ int atcommand_recallid2(
int session_id=0;
struct map_session_data *pl_sd;
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
@@ -9198,7 +9198,7 @@ int atcommand_kickid(
int cid=0;
int session_id=0;
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
@@ -9245,7 +9245,7 @@ int atcommand_kickid2(
int aid=0;
int session_id=0;
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
@@ -9292,7 +9292,7 @@ int atcommand_reviveid(
int session_id=0;
struct map_session_data *pl_sd;
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
@@ -9342,7 +9342,7 @@ int atcommand_reviveid2(
int session_id=0;
struct map_session_data *pl_sd;
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
@@ -9392,7 +9392,7 @@ int atcommand_killid(
int session_id=0;
struct map_session_data *pl_sd;
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
@@ -9440,7 +9440,7 @@ int atcommand_killid2(
int session_id=0;
struct map_session_data *pl_sd;
- memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
@@ -9668,8 +9668,8 @@ int atcommand_mobinfo(
int count;
int i, j, k;
- memset(atcmd_output, '\0', sizeof(atcmd_output));
- memset(atcmd_output2, '\0', sizeof(atcmd_output2));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output2, '\0', sizeof(atcmd_output2));
if (!message || !*message) {
clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
@@ -10240,8 +10240,8 @@ int atcommand_me(
char tempmes[200];
nullpo_retr(-1, sd);
- memset(tempmes, '\0', sizeof(tempmes));
- memset(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(tempmes, '\0', sizeof(tempmes));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
if (sd->sc.count && //no "chatting" while muted.
(sd->sc.data[SC_BERSERK].timer!=-1 ||
@@ -10776,7 +10776,7 @@ int atcommand_request(
void do_init_atcommand() {
users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
duel_count = 0;
- memset(&duel_list[0], 0, sizeof(duel_list));
+ malloc_tsetdword(&duel_list[0], 0, sizeof(duel_list));
return;
}
diff --git a/src/map/battle.c b/src/map/battle.c
index 06af76610..4289b76b2 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -81,7 +81,7 @@ struct block_list* battle_gettargeted(struct block_list *target)
int c = 0;
nullpo_retr(NULL, target);
- memset(bl_list, 0, sizeof(bl_list));
+ malloc_tsetdword(bl_list, 0, sizeof(bl_list));
map_foreachinrange(battle_gettargeted_sub, target, AREA_SIZE, BL_CHAR, bl_list, &c, target->id);
if (c == 0 || c > 24)
return NULL;
@@ -794,8 +794,8 @@ static struct Damage battle_calc_weapon_attack(
unsigned cardfix : 1;
} flag;
- memset(&wd,0,sizeof(wd));
- memset(&flag,0,sizeof(flag));
+ malloc_tsetdword(&wd,0,sizeof(wd));
+ malloc_tsetdword(&flag,0,sizeof(flag));
if(src==NULL || target==NULL)
{
@@ -2105,8 +2105,8 @@ struct Damage battle_calc_magic_attack(
unsigned cardfix : 1;
} flag;
- memset(&ad,0,sizeof(ad));
- memset(&flag,0,sizeof(flag));
+ malloc_tsetdword(&ad,0,sizeof(ad));
+ malloc_tsetdword(&flag,0,sizeof(flag));
if(src==NULL || target==NULL)
{
@@ -2477,8 +2477,8 @@ struct Damage battle_calc_misc_attack(
unsigned cardfix : 1;
} flag;
- memset(&md,0,sizeof(md));
- memset(&flag,0,sizeof(flag));
+ malloc_tsetdword(&md,0,sizeof(md));
+ malloc_tsetdword(&flag,0,sizeof(flag));
if( src == NULL || target == NULL ){
nullpo_info(NLP_MARK);
@@ -2735,7 +2735,7 @@ struct Damage battle_calc_attack( int attack_type,
default:
if (battle_config.error_log)
ShowError("battle_calc_attack: unknown attack type! %d\n",attack_type);
- memset(&d,0,sizeof(d));
+ malloc_tsetdword(&d,0,sizeof(d));
break;
}
if (d.damage + d.damage2 < 1)
diff --git a/src/map/charcommand.c b/src/map/charcommand.c
index 740f7465d..66905faba 100644
--- a/src/map/charcommand.c
+++ b/src/map/charcommand.c
@@ -138,7 +138,7 @@ is_charcommand(const int fd, struct map_session_data* sd, const char* message, i
if (!message || !*message)
return CharCommand_None;
- memset(&info, 0, sizeof(info));
+ malloc_set(&info, 0, sizeof(info));
str += strlen(sd->status.name);
while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
if (*str == ':')
@@ -162,8 +162,8 @@ is_charcommand(const int fd, struct map_session_data* sd, const char* message, i
char command[100];
char output[200];
const char* p = str;
- memset(command, '\0', sizeof(command));
- memset(output, '\0', sizeof(output));
+ malloc_tsetdword(command, '\0', sizeof(command));
+ malloc_tsetdword(output, '\0', sizeof(output));
while (*p && !isspace(*p))
p++;
if (p - str >= sizeof(command)) // too long
@@ -208,7 +208,7 @@ CharCommandType charcommand(struct map_session_data* sd, const int level, const
if (*p == command_symbol) { // check first char.
char command[101];
int i = 0;
- memset(info, 0, sizeof(CharCommandInfo));
+ malloc_set(info, 0, sizeof(CharCommandInfo));
sscanf(p, "%100s", command);
command[sizeof(command)-1] = '\0';
@@ -307,7 +307,7 @@ int charcommand_jobchange(
struct map_session_data* pl_sd;
int job = 0, upper = -1;
- memset(character, '\0', sizeof(character));
+ malloc_tsetdword(character, '\0', sizeof(character));
if (!message || !*message) {
clif_displaymessage(fd, "Please, enter a job and a player name (usage: #job/#jobchange <job ID> <char name>).");
@@ -364,7 +364,7 @@ int charcommand_petrename(
struct map_session_data *pl_sd;
struct pet_data *pd;
- memset(character, '\0', sizeof(character));
+ malloc_tsetdword(character, '\0', sizeof(character));
if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: #petrename <char name>).");
@@ -408,7 +408,7 @@ int charcommand_petfriendly(
struct map_session_data *pl_sd;
struct pet_data *pd;
- memset(character, '\0', sizeof(character));
+ malloc_tsetdword(character, '\0', sizeof(character));
if (!message || !*message || sscanf(message,"%d %23s",&friendly,character) < 2) {
clif_displaymessage(fd, "Please, enter a valid value (usage: "
"#petfriendly <0-1000> <player>).");
@@ -459,9 +459,9 @@ int charcommand_stats(
struct map_session_data *pl_sd;
int i;
- memset(character, '\0', sizeof(character));
- memset(job_jobname, '\0', sizeof(job_jobname));
- memset(output, '\0', sizeof(output));
+ malloc_tsetdword(character, '\0', sizeof(character));
+ malloc_tsetdword(job_jobname, '\0', sizeof(job_jobname));
+ malloc_tsetdword(output, '\0', sizeof(output));
if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: #stats <char name>).");
@@ -530,8 +530,8 @@ int charcommand_reset(
char output[200];
struct map_session_data *pl_sd;
- memset(character, '\0', sizeof(character));
- memset(output, '\0', sizeof(output));
+ malloc_tsetdword(character, '\0', sizeof(character));
+ malloc_tsetdword(output, '\0', sizeof(output));
if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: #reset <charname>).");
@@ -568,7 +568,7 @@ int charcommand_option(
int opt1 = 0, opt2 = 0, opt3 = 0;
struct map_session_data* pl_sd;
- memset(character, '\0', sizeof(character));
+ malloc_tsetdword(character, '\0', sizeof(character));
if (!message || !*message ||
sscanf(message, "%d %d %d %23[^\n]", &opt1, &opt2, &opt3, character) < 4 ||
@@ -609,8 +609,8 @@ int charcommand_save(
int x = 0, y = 0;
int m;
- memset(map_name, '\0', sizeof(map_name));
- memset(character, '\0', sizeof(character));
+ malloc_tsetdword(map_name, '\0', sizeof(map_name));
+ malloc_tsetdword(character, '\0', sizeof(character));
if (!message || !*message || sscanf(message, "%15s %d %d %23[^\n]", map_name, &x, &y, character) < 4 || x < 0 || y < 0) {
clif_displaymessage(fd, "Please, enter a valid save point and a player name (usage: #save <map> <x> <y> <charname>).");
@@ -662,8 +662,8 @@ int charcommand_stats_all(const int fd, struct map_session_data* sd, const char*
int count, users;
struct map_session_data *pl_sd, **pl_allsd;
- memset(output, '\0', sizeof(output));
- memset(gmlevel, '\0', sizeof(gmlevel));
+ malloc_tsetdword(output, '\0', sizeof(output));
+ malloc_tsetdword(gmlevel, '\0', sizeof(gmlevel));
count = 0;
pl_allsd = map_getallusers(&users);
@@ -706,7 +706,7 @@ int charcommand_spiritball(const int fd, struct map_session_data* sd,const char*
char character[NAME_LENGTH];
int spirit = 0;
- memset(character, '\0', sizeof(character));
+ malloc_tsetdword(character, '\0', sizeof(character));
if(!message || !*message || sscanf(message, "%d %23[^\n]", &spirit, character) < 2 || spirit < 0 || spirit > 1000) {
clif_displaymessage(fd, "Usage: @spiritball <number: 0-1000>) <CHARACTER_NAME>.");
@@ -754,10 +754,10 @@ charcommand_itemlist(
struct item *i_item; //Current inventory item.
nullpo_retr(-1, sd);
- memset(character, '\0', sizeof(character));
- memset(output, '\0', sizeof(output));
- memset(equipstr, '\0', sizeof(equipstr));
- memset(outputtmp, '\0', sizeof(outputtmp));
+ malloc_tsetdword(character, '\0', sizeof(character));
+ malloc_tsetdword(output, '\0', sizeof(output));
+ malloc_tsetdword(equipstr, '\0', sizeof(equipstr));
+ malloc_tsetdword(outputtmp, '\0', sizeof(outputtmp));
if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: #itemlist <char name>).");
@@ -810,13 +810,13 @@ charcommand_itemlist(
// remove final ', '
equipstr[strlen(equipstr) - 2] = '\0';
} else
- memset(equipstr, '\0', sizeof(equipstr));
+ malloc_tsetdword(equipstr, '\0', sizeof(equipstr));
if (i_item->refine)
sprintf(output, "%d %s %+d (%s %+d, id: %d) %s", i_item->amount, item_data->name, i_item->refine, item_data->jname, i_item->refine, i_item->nameid, equipstr);
else
sprintf(output, "%d %s (%s, id: %d) %s", i_item->amount, item_data->name, item_data->jname, i_item->nameid, equipstr);
clif_displaymessage(fd, output);
- memset(output, '\0', sizeof(output));
+ malloc_tsetdword(output, '\0', sizeof(output));
counter2 = 0;
if(i_item->card[0]==CARD0_PET) { //pet eggs
@@ -914,9 +914,9 @@ charcommand_storagelist(
char character[NAME_LENGTH], output[200], outputtmp[200];
nullpo_retr(-1, sd);
- memset(character, '\0', sizeof(character));
- memset(output, '\0', sizeof(output));
- memset(outputtmp, '\0', sizeof(outputtmp));
+ malloc_tsetdword(character, '\0', sizeof(character));
+ malloc_tsetdword(output, '\0', sizeof(output));
+ malloc_tsetdword(outputtmp, '\0', sizeof(outputtmp));
if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: #itemlist <char name>).");
@@ -941,7 +941,7 @@ charcommand_storagelist(
else
sprintf(output, "%d %s (%s, id: %d)", stor->storage_[i].amount, item_data->name, item_data->jname, stor->storage_[i].nameid);
clif_displaymessage(fd, output);
- memset(output, '\0', sizeof(output));
+ malloc_tsetdword(output, '\0', sizeof(output));
counter2 = 0;
for (j = 0; j < item_data->slot; j++) {
if (stor->storage_[i].card[j]) {
@@ -997,7 +997,7 @@ charcommand_giveitem_sub(struct map_session_data *sd,struct item_data *item_data
get_count = 1;
}
for (i = 0; i < loop; i++) {
- memset(&item_tmp, 0, sizeof(item_tmp));
+ malloc_set(&item_tmp, 0, sizeof(item_tmp));
item_tmp.nameid = item_data->nameid;
item_tmp.identify = 1;
@@ -1030,7 +1030,7 @@ int charcommand_item(
char tmp_cmdoutput[1024];
nullpo_retr(-1, sd);
- memset(item_name, '\0', sizeof(item_name));
+ malloc_tsetdword(item_name, '\0', sizeof(item_name));
if (!message || !*message || sscanf(message, "%99s %d %23[^\n]", item_name, &number, character) < 3) {
clif_displaymessage(fd, "Please, enter an item name/id (usage: #item <item name or ID> <quantity> <char name>).");
@@ -1065,7 +1065,7 @@ int charcommand_item(
100, 0, 1, pet_db[pet_id].jname);
// if not pet egg
} else {
- memset(&item_tmp, 0, sizeof(item_tmp));
+ malloc_set(&item_tmp, 0, sizeof(item_tmp));
item_tmp.nameid = item_id;
item_tmp.identify = 1;
@@ -1124,8 +1124,8 @@ int charcommand_warp(
nullpo_retr(-1, sd);
- memset(map_name, '\0', sizeof(map_name));
- memset(character, '\0', sizeof(character));
+ malloc_tsetdword(map_name, '\0', sizeof(map_name));
+ malloc_tsetdword(character, '\0', sizeof(character));
if (!message || !*message || sscanf(message, "%15s %d %d %23[^\n]", map_name, &x, &y, character) < 4) {
clif_displaymessage(fd, "Usage: #warp/#rura/#rura+ <mapname> <x> <y> <char name>");
@@ -1182,7 +1182,7 @@ int charcommand_zeny(
int zeny = 0, new_zeny;
nullpo_retr(-1, sd);
- memset(character, '\0', sizeof(character));
+ malloc_tsetdword(character, '\0', sizeof(character));
if (!message || !*message || sscanf(message, "%d %23[^\n]", &zeny, character) < 2 || zeny == 0) {
clif_displaymessage(fd, "Please, enter a number and a player name (usage: #zeny <zeny> <name>).");
@@ -1766,8 +1766,8 @@ int charcommand_feelreset(
char output[200];
struct map_session_data *pl_sd;
- memset(character, '\0', sizeof(character));
- memset(output, '\0', sizeof(output));
+ malloc_tsetdword(character, '\0', sizeof(character));
+ malloc_tsetdword(output, '\0', sizeof(output));
if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: #feelreset <charname>).");
@@ -1804,7 +1804,7 @@ int charcommand_help(
FILE* fp;
nullpo_retr(-1, sd);
- memset(buf, '\0', sizeof(buf));
+ malloc_tsetdword(buf, '\0', sizeof(buf));
if ((fp = fopen(charhelp_txt, "r")) != NULL) {
clif_displaymessage(fd, msg_table[26]); /* Help commands: */
diff --git a/src/map/chrif.c b/src/map/chrif.c
index f4def8091..6f3e35c0d 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -1170,9 +1170,9 @@ int chrif_recvfamelist(int fd)
int total = 0, len = 8;
RFIFOHEAD(fd);
- memset (smith_fame_list, 0, sizeof(smith_fame_list));
- memset (chemist_fame_list, 0, sizeof(chemist_fame_list));
- memset (taekwon_fame_list, 0, sizeof(taekwon_fame_list));
+ malloc_tsetdword (smith_fame_list, 0, sizeof(smith_fame_list));
+ malloc_tsetdword (chemist_fame_list, 0, sizeof(chemist_fame_list));
+ malloc_tsetdword (taekwon_fame_list, 0, sizeof(taekwon_fame_list));
size = RFIFOW(fd, 6); //Blacksmith block size
for (num = 0; len < size && num < MAX_FAME_LIST; num++) {
@@ -1319,7 +1319,7 @@ int chrif_load_scdata(int fd)
}
fclose(fp);
} else {
- memset(buf, 0, sizeof(buf)); //No data found, send empty packets?
+ malloc_tsetdword(buf, 0, sizeof(buf)); //No data found, send empty packets?
WFIFOW(char_fd,8) = sizeof(buf) + 10;
memcpy(WFIFOP(char_fd,10), buf, sizeof(buf));
}
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();
diff --git a/src/map/guild.c b/src/map/guild.c
index ff972ffd9..de23c4254 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -94,7 +94,7 @@ int guild_read_guildskill_tree_db(void)
FILE *fp;
char line[1024],*p;
- memset(guild_skill_tree,0,sizeof(guild_skill_tree));
+ malloc_set(guild_skill_tree,0,sizeof(guild_skill_tree));
sprintf(line, "%s/guild_skill_tree.txt", db_path);
if( (fp=fopen(line,"r"))==NULL){
ShowError("can't read %s\n", line);
@@ -170,7 +170,7 @@ static int guild_read_castledb(void)
while(fgets(line,1020,fp)){
if(line[0]=='/' && line[1]=='/')
continue;
- memset(str,0,sizeof(str));
+ malloc_tsetdword(str,0,sizeof(str));
for(j=0,p=line;j<6 && p;j++){
str[j]=p;
p=strchr(p,',');
@@ -325,7 +325,7 @@ void guild_makemember(struct guild_member *m,struct map_session_data *sd)
{
nullpo_retv(sd);
- memset(m,0,sizeof(struct guild_member));
+ malloc_set(m,0,sizeof(struct guild_member));
m->account_id =sd->status.account_id;
m->char_id =sd->status.char_id;
m->hair =sd->status.hair;
@@ -816,7 +816,7 @@ int guild_expulsion(struct map_session_data *sd,int guild_id,
intif_guild_leave(g->guild_id,account_id,char_id,1,mes);
//It's wrong way, member info will erased later
//see guild_member_leaved [LuzZza]
- //memset(&g->member[i],0,sizeof(struct guild_member));
+ //malloc_set(&g->member[i],0,sizeof(struct guild_member));
return 0;
}
}
@@ -846,7 +846,7 @@ int guild_member_leaved(int guild_id,int account_id,int char_id,int flag,
else
clif_guild_expulsion(online_member_sd, name, mes, account_id);
- memset(&g->member[i],0,sizeof(struct guild_member));
+ malloc_set(&g->member[i],0,sizeof(struct guild_member));
clif_guild_memberlist(online_member_sd);
if(sd != NULL && sd->status.guild_id == guild_id) {
diff --git a/src/map/irc.c b/src/map/irc.c
index 9d59fba68..908e8220a 100644
--- a/src/map/irc.c
+++ b/src/map/irc.c
@@ -58,7 +58,7 @@ int irc_connect_timer(int tid, unsigned int tick, int id, int data)
void irc_announce(char *buf)
{
char send_string[256];
- memset(send_string,'\0',256);
+ malloc_tsetdword(send_string,'\0',256);
sprintf(send_string,"PRIVMSG %s :%s",irc_channel, buf);
irc_send(send_string);
@@ -69,7 +69,7 @@ void irc_announce_jobchange(struct map_session_data *sd)
char send_string[256];
nullpo_retv(sd);
- memset(send_string,'\0',256);
+ malloc_tsetdword(send_string,'\0',256);
sprintf(send_string,"PRIVMSG %s :%s has changed into a %s.",irc_channel,sd->status.name,job_name(sd->status.class_));
irc_send(send_string);
@@ -82,8 +82,8 @@ void irc_announce_shop(struct map_session_data *sd, int flag)
int maplen = 0;
nullpo_retv(sd);
- memset(send_string,'\0',256);
- memset(mapname,'\0',16);
+ malloc_tsetdword(send_string,'\0',256);
+ malloc_tsetdword(mapname,'\0',16);
if(flag){
strcpy(mapname, map[sd->bl.m].name);
@@ -107,8 +107,8 @@ void irc_announce_mvp(struct map_session_data *sd, struct mob_data *md)
nullpo_retv(sd);
nullpo_retv(md);
- memset(send_string,'\0',256);
- memset(mapname,'\0',16);
+ malloc_tsetdword(send_string,'\0',256);
+ malloc_tsetdword(mapname,'\0',16);
mapname[15]='\0'; // 15 is the final index, not 16 [Lance]
strcpy(mapname, map[md->bl.m].name);
maplen = strcspn(mapname,".");
@@ -149,7 +149,7 @@ int irc_parse(int fd)
int irc_keepalive_timer(int tid, unsigned int tick, int id, int data)
{
char send_string[128];
- memset(send_string,'\0',128);
+ malloc_tsetdword(send_string,'\0',128);
sprintf(send_string,"PRIVMSG %s : ", irc_nick);
irc_send(send_string);
@@ -172,7 +172,7 @@ void irc_send(char *buf)
if(!irc_si || !session[irc_si->fd])
return;
- memset(transmit,'\0',4096);
+ malloc_tsetdword(transmit,'\0',4096);
sprintf(transmit,buf);
irc_send_sub(irc_si->fd,transmit);
@@ -200,16 +200,16 @@ void irc_parse_sub(int fd, char *incoming_string)
struct map_session_data **allsd;
- memset(source,'\0',256);
- memset(command,'\0',256);
- memset(target,'\0',256);
- memset(message,'\0',8192);
- memset(send_string,'\0',8192);
+ malloc_tsetdword(source,'\0',256);
+ malloc_tsetdword(command,'\0',256);
+ malloc_tsetdword(target,'\0',256);
+ malloc_tsetdword(message,'\0',8192);
+ malloc_tsetdword(send_string,'\0',8192);
- memset(cmd1,'\0',256);
- memset(cmd2,'\0',256);
- memset(cmdname,'\0',256);
- memset(cmdargs,'\0',256);
+ malloc_tsetdword(cmd1,'\0',256);
+ malloc_tsetdword(cmd2,'\0',256);
+ malloc_tsetdword(cmdname,'\0',256);
+ malloc_tsetdword(cmdargs,'\0',256);
sscanf(incoming_string, ":%255s %255s %255s :%4095[^\r\n]", source, command, target, message);
if (source != NULL) {
@@ -364,11 +364,11 @@ int parse_names_packet(char *str) {
char channel[256];
char names[1024];
- memset(source,'\0',256);
- memset(numeric,'\0',10);
- memset(target,'\0',256);
- memset(channel,'\0',256);
- memset(names,'\0',1024);
+ malloc_tsetdword(source,'\0',256);
+ malloc_tsetword(numeric,'\0',10);
+ malloc_tsetdword(target,'\0',256);
+ malloc_tsetdword(channel,'\0',256);
+ malloc_tsetdword(names,'\0',1024);
tok=strtok(str,"\r\n");
sscanf(tok,":%255s %10s %255s %*1[=@] %255s :%1023[^\r\n]",source,numeric,target,channel,names);
@@ -471,7 +471,7 @@ int irc_rmnames() {
int i=0;
for(i=0;i<=MAX_CHANNEL_USERS;i++) {
- //memset(cd.user[i].name,'\0',256);
+ //malloc_tsetdword(cd.user[i].name,'\0',256);
cd.user[i].level=0;
}
@@ -488,10 +488,10 @@ int irc_read_conf(char *file) {
char path[256];
char row[1024];
- memset(w1,'\0',256);
- memset(w2,'\0',256);
- memset(path,'\0',256);
- memset(row,'\0',256);
+ malloc_tsetdword(w1,'\0',256);
+ malloc_tsetdword(w2,'\0',256);
+ malloc_tsetdword(path,'\0',256);
+ malloc_tsetdword(row,'\0',256);
sprintf(path,"conf/%s",file);
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index f4de37cfa..51560f8db 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -209,7 +209,7 @@ static void itemdb_jobid2mapid(unsigned int *bclass, unsigned int jobmask)
}
static void create_dummy_data(void) {
- memset(&dummy_item, 0, sizeof(struct item_data));
+ malloc_set(&dummy_item, 0, sizeof(struct item_data));
dummy_item.nameid=500;
dummy_item.weight=1;
dummy_item.value_sell = 1;
@@ -427,7 +427,7 @@ static int itemdb_read_itemavail (void)
while (fgets(line, sizeof(line) - 1, fp)) {
if (line[0] == '/' && line[1] == '/')
continue;
- memset(str, 0, sizeof(str));
+ malloc_tsetdword(str, 0, sizeof(str));
for (j = 0, p = line; j < 2 && p; j++) {
str[j] = p;
p = strchr(p, ',');
@@ -481,7 +481,7 @@ static void itemdb_read_itemgroup_sub(const char* filename)
continue;
}
}
- memset(str,0,sizeof(str));
+ malloc_tsetdword(str,0,sizeof(str));
for(j=0,p=line;j<3 && p;j++){
str[j]=p;
p=strchr(p,',');
@@ -554,7 +554,7 @@ static void itemdb_read_itemgroup(void)
"Gift Box China",
"Lotto Box",
};
- memset(&itemgroup_db, 0, sizeof(itemgroup_db));
+ malloc_tsetdword(&itemgroup_db, 0, sizeof(itemgroup_db));
snprintf(path, 255, "%s/item_group_db.txt", db_path);
itemdb_read_itemgroup_sub(path);
ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n","item_group_db.txt");
@@ -732,7 +732,7 @@ static int itemdb_read_noequip(void)
while(fgets(line,1020,fp)){
if(line[0]=='/' && line[1]=='/')
continue;
- memset(str,0,sizeof(str));
+ malloc_tsetdword(str,0,sizeof(str));
for(j=0,p=line;j<2 && p;j++){
str[j]=p;
p=strchr(p,',');
@@ -777,7 +777,7 @@ static int itemdb_read_itemtrade(void)
while (fgets(line, sizeof(line) - 1, fp)) {
if (line[0] == '/' && line[1] == '/')
continue;
- memset(str, 0, sizeof(str));
+ malloc_tsetdword(str, 0, sizeof(str));
for (j = 0, p = line; j < 3 && p; j++) {
str[j] = p;
p = strchr(p, ',');
@@ -1032,7 +1032,7 @@ static int itemdb_readdb(void)
lines++;
if(line[0]=='/' && line[1]=='/')
continue;
- memset(str,0,sizeof(str));
+ malloc_tsetdword(str,0,sizeof(str));
for(j=0,np=p=line;j<19 && p;j++){
str[j]=p;
p=strchr(p,',');
diff --git a/src/map/log.c b/src/map/log.c
index cbcdaf0f7..02a77d0d2 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -361,7 +361,7 @@ return -1;
void log_set_defaults(void)
{
- memset(&log_config, 0, sizeof(log_config));
+ malloc_set(&log_config, 0, sizeof(log_config));
//LOG FILTER Default values
log_config.refine_items_log = 5; //log refined items, with refine >= +7
diff --git a/src/map/map.c b/src/map/map.c
index a668ecad8..81e62b875 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -2542,7 +2542,7 @@ static int map_cache_open(char *fn)
// 読み甲ンに失敗したので新規に作成する
map_cache.fp = fopen(fn,"wb");
if(map_cache.fp) {
- memset(&map_cache.head,0,sizeof(struct map_cache_head));
+ malloc_set(&map_cache.head,0,sizeof(struct map_cache_head));
map_cache.map = (struct map_cache_info *) aCalloc(sizeof(struct map_cache_info),MAX_MAP_CACHE);
map_cache.head.nmaps = MAX_MAP_CACHE;
map_cache.head.sizeof_header = sizeof(struct map_cache_head);
@@ -3107,7 +3107,7 @@ int map_readallmaps (void)
// pre-init some data
map[i].alias = NULL;
map[i].m = i;
- memset (map[i].moblist, 0, sizeof(map[i].moblist)); //Initialize moblist [Skotlex]
+ malloc_set (map[i].moblist, 0, sizeof(map[i].moblist)); //Initialize moblist [Skotlex]
map[i].mob_delete_timer = -1; //Initialize timer [Skotlex]
if (battle_config.pk_mode)
map[i].flag.pvp = 1; // make all maps pvp for pk_mode [Valaris]
@@ -3225,7 +3225,7 @@ int parse_console(char *buf) {
int m, n;
struct map_session_data sd;
- memset(&sd, 0, sizeof(struct map_session_data));
+ malloc_set(&sd, 0, sizeof(struct map_session_data));
strcpy( sd.status.name , "console");
if ( ( n = sscanf(buf, "%[^:]:%[^:]:%99s %d %d[^\n]", type , command , map , &x , &y )) < 5 )
diff --git a/src/map/mercenary.c b/src/map/mercenary.c
index 152340fc8..5ba260c18 100644
--- a/src/map/mercenary.c
+++ b/src/map/mercenary.c
@@ -795,7 +795,7 @@ int read_homunculusdb()
char *filename[]={"homunculus_db.txt","homunculus_db2.txt"};
char *str[36];
- memset(homunculus_db,0,sizeof(homunculus_db));
+ malloc_set(homunculus_db,0,sizeof(homunculus_db));
for(i = 0; i<2; i++)
{
sprintf(line, "%s/%s", db_path, filename[i]);
@@ -882,7 +882,7 @@ int read_homunculus_skilldb()
int j = 0;
char *split[15];
- memset(hskill_tree,0,sizeof(hskill_tree));
+ malloc_tsetdword(hskill_tree,0,sizeof(hskill_tree));
sprintf(line, "%s/homun_skill_tree.txt", db_path);
fp=fopen(line,"r");
if(fp==NULL){
@@ -949,7 +949,7 @@ void read_homunculus_expdb()
int i, j=0;
char *filename[]={"exp_homun.txt","exp_homun2.txt"};
- memset(hexptbl,0,sizeof(hexptbl));
+ malloc_tsetdword(hexptbl,0,sizeof(hexptbl));
for(i=0; i<2; i++){
sprintf(line, "%s/%s", db_path, filename[i]);
fp=fopen(line,"r");
diff --git a/src/map/mob.c b/src/map/mob.c
index 97e90efda..8c38374ef 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -261,7 +261,7 @@ struct mob_data *mob_once_spawn_sub(struct block_list *bl, int m,
{
struct spawn_data data;
- memset(&data, 0, sizeof(struct spawn_data));
+ malloc_set(&data, 0, sizeof(struct spawn_data));
data.m = m;
data.num = 1;
data.class_ = class_;
@@ -450,7 +450,7 @@ int mob_spawn_guardian(struct map_session_data *sd,char *mapname,
struct guild *g=NULL;
struct guild_castle *gc;
int m, count;
- memset(&data, 0, sizeof(struct spawn_data));
+ malloc_set(&data, 0, sizeof(struct spawn_data));
data.num = 1;
if( sd && strcmp(mapname,"this")==0)
@@ -655,7 +655,7 @@ int mob_spawn (struct mob_data *md)
}
}
}
- memset(&md->state, 0, sizeof(md->state));
+ malloc_set(&md->state, 0, sizeof(md->state));
status_calc_mob(md, 1);
md->attacked_id = 0;
md->attacked_players = 0;
@@ -674,10 +674,10 @@ int mob_spawn (struct mob_data *md)
for (i = 0, c = tick-1000*3600*10; i < MAX_MOBSKILL; i++)
md->skilldelay[i] = c;
- memset(md->dmglog, 0, sizeof(md->dmglog));
+ malloc_set(md->dmglog, 0, sizeof(md->dmglog));
md->tdmg = 0;
if (md->lootitem)
- memset(md->lootitem, 0, sizeof(md->lootitem));
+ malloc_set(md->lootitem, 0, sizeof(md->lootitem));
md->lootitem_count = 0;
if(md->db->option)
@@ -1418,7 +1418,7 @@ static int mob_ai_hard(int tid,unsigned int tick,int id,int data)
static struct item_drop* mob_setdropitem(int nameid, int qty)
{
struct item_drop *drop = ers_alloc(item_drop_ers, struct item_drop);
- memset(&drop->item_data, 0, sizeof(struct item));
+ malloc_set(&drop->item_data, 0, sizeof(struct item));
drop->item_data.nameid = nameid;
drop->item_data.amount = qty;
drop->item_data.identify = itemdb_isidentified(nameid);
@@ -1723,8 +1723,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
map_freeblock_lock();
- memset(tmpbl,0,sizeof(tmpbl));
- memset(pt,0,sizeof(pt));
+ malloc_tsetdword(tmpbl,0,sizeof(tmpbl));
+ malloc_set(pt,0,sizeof(pt));
if(src && src->type == BL_MOB)
mob_unlocktarget((struct mob_data *)src,tick);
@@ -2075,7 +2075,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
if(temp <= rand()%10000+1) //if ==0, then it doesn't drop
continue;
- memset(&item,0,sizeof(item));
+ malloc_set(&item,0,sizeof(item));
item.nameid=md->db->mvpitem[i].nameid;
item.identify= itemdb_isidentified(item.nameid);
clif_mvp_item(mvp_sd,item.nameid);
@@ -2288,7 +2288,7 @@ int mob_class_change (struct mob_data *md, int class_)
status_calc_mob(md, 3);
if (battle_config.monster_class_change_full_recover) {
- memset(md->dmglog, 0, sizeof(md->dmglog));
+ malloc_set(md->dmglog, 0, sizeof(md->dmglog));
md->tdmg = 0;
} else {
md->status.hp = md->status.max_hp*hp_rate/100;
@@ -2392,7 +2392,7 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,int skill_id)
nullpo_retr(0, md2);
nullpo_retr(0, value);
- memset(&data, 0, sizeof(struct spawn_data));
+ malloc_set(&data, 0, sizeof(struct spawn_data));
data.m = md2->bl.m;
data.x = md2->bl.x;
data.y = md2->bl.y;
@@ -2893,7 +2893,7 @@ int mob_clone_spawn(struct map_session_data *sd, int m, int x, int y, const char
skill_get_unit_flag(skill_id)&(UF_NOMOB|UF_NOPC))
continue;
- memset (&ms[i], 0, sizeof(struct mob_skill));
+ malloc_set (&ms[i], 0, sizeof(struct mob_skill));
ms[i].skill_id = skill_id;
ms[i].skill_lv = sd->status.skill[skill_id].lv;
ms[i].state = MSS_ANY;
@@ -3419,7 +3419,7 @@ static int mob_readdb_mobavail(void)
while(fgets(line,1020,fp)){
if(line[0]=='/' && line[1]=='/')
continue;
- memset(str,0,sizeof(str));
+ malloc_tsetdword(str,0,sizeof(str));
for(j=0,p=line;j<12;j++){
if((np=strchr(p,','))!=NULL){
@@ -3444,7 +3444,7 @@ static int mob_readdb_mobavail(void)
if(k < 0)
continue;
- memset(&mob_db_data[class_]->vd, 0, sizeof(struct view_data));
+ malloc_set(&mob_db_data[class_]->vd, 0, sizeof(struct view_data));
mob_db_data[class_]->vd.class_=k;
//Player sprites
@@ -3498,7 +3498,7 @@ static int mob_read_randommonster(void)
int class_,per;
if(line[0] == '/' && line[1] == '/')
continue;
- memset(str,0,sizeof(str));
+ malloc_tsetdword(str,0,sizeof(str));
for(j=0,p=line;j<3 && p;j++){
str[j]=p;
p=strchr(p,',');
@@ -3623,7 +3623,7 @@ static int mob_readskilldb(void)
if(line[0] == '/' && line[1] == '/')
continue;
- memset(sp,0,sizeof(sp));
+ malloc_tsetdword(sp,0,sizeof(sp));
for(i=0,p=line;i<18 && p;i++){
sp[i]=p;
if((p=strchr(p,','))!=NULL)
@@ -3646,14 +3646,14 @@ static int mob_readskilldb(void)
if( strcmp(sp[1],"clear")==0 ){
if (mob_id < 0)
continue;
- memset(mob_db_data[mob_id]->skill,0,sizeof(struct mob_skill));
+ malloc_set(mob_db_data[mob_id]->skill,0,sizeof(struct mob_skill));
mob_db_data[mob_id]->maxskill=0;
continue;
}
if (mob_id < 0)
{ //Prepare global skill. [Skotlex]
- memset(&gms, 0, sizeof (struct mob_skill));
+ malloc_set(&gms, 0, sizeof (struct mob_skill));
ms = &gms;
} else {
for(i=0;i<MAX_MOBSKILL;i++)
@@ -3788,7 +3788,7 @@ static int mob_readdb_race(void)
while(fgets(line,1020,fp)){
if(line[0]=='/' && line[1]=='/')
continue;
- memset(str,0,sizeof(str));
+ malloc_tsetdword(str,0,sizeof(str));
for(j=0,p=line;j<12;j++){
if((np=strchr(p,','))!=NULL){
@@ -4099,7 +4099,7 @@ void mob_reload(void)
for (i = 0; i < MAX_MOB_DB; i++)
if (mob_db_data[i])
{
- memset(&mob_db_data[i]->skill,0,sizeof(mob_db_data[i]->skill));
+ malloc_set(&mob_db_data[i]->skill,0,sizeof(mob_db_data[i]->skill));
mob_db_data[i]->maxskill=0;
}
mob_readskilldb();
@@ -4112,7 +4112,7 @@ void mob_reload(void)
*/
int do_init_mob(void)
{ //Initialize the mob database
- memset(mob_db_data,0,sizeof(mob_db_data)); //Clear the array
+ malloc_set(mob_db_data,0,sizeof(mob_db_data)); //Clear the array
mob_db_data[0] = aCalloc(1, sizeof (struct mob_data)); //This mob is used for random spawns
mob_makedummymobdb(0); //The first time this is invoked, it creates the dummy mob
item_drop_ers = ers_new((uint32)sizeof(struct item_drop));
diff --git a/src/map/npc.c b/src/map/npc.c
index 8b1f39b72..cd6e0b997 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -1232,7 +1232,7 @@ int npc_buylist(struct map_session_data *sd,int n,unsigned short *item_list)
for(i=0;i<n;i++) {
struct item item_tmp;
- memset(&item_tmp,0,sizeof(item_tmp));
+ malloc_set(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid = item_list[i*2+1];
item_tmp.identify = 1; // npc販売アイテムは鑑定済み
@@ -1797,7 +1797,7 @@ static int npc_skip_script (char *w1,char *w2,char *w3,char *w4,char *first_line
if (strlen((char *)srcbuf) + strlen((char *)line) + 1 >= (size_t)srcsize) {
srcsize += 65536;
srcbuf = (unsigned char *)aRealloc(srcbuf, srcsize);
- memset(srcbuf + srcsize - 65536, '\0', 65536);
+ malloc_tsetdword(srcbuf + srcsize - 65536, '\0', 65536);
}
if (srcbuf[0] != '{') {
if (strchr((char *) line,'{')) {
@@ -1861,7 +1861,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
if (strlen((char *)srcbuf) + strlen((char *)line) + 1 >= (size_t)srcsize) {
srcsize += 65536;
srcbuf = (unsigned char *)aRealloc(srcbuf, srcsize);
- memset(srcbuf + srcsize - 65536, '\0', 65536);
+ malloc_tsetdword(srcbuf + srcsize - 65536, '\0', 65536);
}
if (srcbuf[0] != '{') {
if (strchr((char *) line,'{')) {
@@ -2097,7 +2097,7 @@ static int npc_parse_function (char *w1, char *w2, char *w3, char *w4, char *fir
if (strlen(srcbuf)+strlen(line)+1 >= (unsigned int)srcsize) {
srcsize += 65536;
srcbuf = (char *)aRealloc(srcbuf, srcsize);
- memset(srcbuf + srcsize - 65536, '\0', 65536);
+ malloc_tsetdword(srcbuf + srcsize - 65536, '\0', 65536);
}
if (srcbuf[0]!='{') {
if (strchr(line,'{')) {
@@ -2172,7 +2172,7 @@ int npc_parse_mob (char *w1, char *w2, char *w3, char *w4)
char mobname[NAME_LENGTH];
struct spawn_data mob, *data;
- memset(&mob, 0, sizeof(struct spawn_data));
+ malloc_set(&mob, 0, sizeof(struct spawn_data));
// 引数の個数チェック
if (sscanf(w1, "%15[^,],%d,%d,%d,%d", mapname, &x, &y, &xs, &ys) < 3 ||
@@ -2805,7 +2805,7 @@ int npc_reload (void)
if(battle_config.dynamic_mobs) { //dynamic check by [random]
for (i = 0; i < MAX_MOB_LIST_PER_MAP; i++)
if (map[m].moblist[i]) aFree(map[m].moblist[i]);
- memset (map[m].moblist, 0, sizeof(map[m].moblist));
+ malloc_set (map[m].moblist, 0, sizeof(map[m].moblist));
}
if (map[m].npc_num > 0 && battle_config.error_log)
ShowWarning("npc_reload: %d npcs weren't removed at map %s!\n", map[m].npc_num, map[m].name);
@@ -2945,7 +2945,7 @@ int do_init_npc(void)
char c = '-';
//Stock view data for normal npcs.
- memset(&npc_viewdb, 0, sizeof(npc_viewdb));
+ malloc_set(&npc_viewdb, 0, sizeof(npc_viewdb));
npc_viewdb[0].class_ = INVISIBLE_CLASS; //Invisible class is stored here.
for (busy = 1; busy < MAX_NPC_CLASS; busy++)
npc_viewdb[busy].class_ = busy;
@@ -2959,7 +2959,7 @@ int do_init_npc(void)
ev_db = db_alloc(__FILE__,__LINE__,DB_STRING,DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA,51);
npcname_db = db_alloc(__FILE__,__LINE__,DB_STRING,DB_OPT_BASE,NAME_LENGTH);
- memset(&ev_tm_b, -1, sizeof(ev_tm_b));
+ malloc_set(&ev_tm_b, -1, sizeof(ev_tm_b));
timer_event_ers = ers_new((uint32)sizeof(struct timer_event_data));
for (nsl = npc_src_first; nsl; nsl = nsl->next) {
@@ -2993,7 +2993,7 @@ int do_init_npc(void)
CL_WHITE"%d"CL_RESET"' Mobs Not Cached\n",
npc_id - START_NPC_NUM, "", npc_warp, npc_shop, npc_script, npc_mob, npc_cache_mob, npc_delay_mob);
- memset(script_event, 0, sizeof(script_event));
+ malloc_set(script_event, 0, sizeof(script_event));
npc_read_event_script();
//Debug function to locate all endless loop warps.
if (battle_config.warp_point_debug)
diff --git a/src/map/party.c b/src/map/party.c
index 650b8b7c2..10ab78e5b 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -194,7 +194,7 @@ static void* create_party(DBKey key, va_list args) {
static void party_check_state(struct party_data *p)
{
int i;
- memset(&p->state, 0, sizeof(p->state));
+ malloc_set(&p->state, 0, sizeof(p->state));
for (i = 0; i < MAX_PARTY; i ++)
{
if (!p->party.member[i].online) continue; //Those not online shouldn't aport to skill usage and all that.
@@ -230,8 +230,8 @@ int party_recv_info(struct party *sp)
if (!p->party.party_id) //party just received.
party_check_member(sp);
memcpy(&p->party,sp,sizeof(struct party));
- memset(&p->state, 0, sizeof(p->state));
- memset(&p->data, 0, sizeof(p->data));
+ malloc_set(&p->state, 0, sizeof(p->state));
+ malloc_set(&p->data, 0, sizeof(p->data));
for(i=0;i<MAX_PARTY;i++){
if (!p->party.member[i].account_id)
continue;
@@ -416,8 +416,8 @@ int party_member_leaved(int party_id,int account_id,int char_id)
if(p->party.member[i].account_id==account_id &&
p->party.member[i].char_id==char_id){
clif_party_leaved(p,sd,account_id,p->party.member[i].name,0x00);
- memset(&p->party.member[i], 0, sizeof(p->party.member[0]));
- memset(&p->data[i], 0, sizeof(p->data[0]));
+ malloc_set(&p->party.member[i], 0, sizeof(p->party.member[0]));
+ malloc_set(&p->data[i], 0, sizeof(p->data[0]));
p->party.count--;
party_check_state(p);
break;
@@ -566,7 +566,7 @@ int party_send_logout(struct map_session_data *sd)
for(i=0;i<MAX_PARTY && p->data[i].sd != sd;i++);
if (i < MAX_PARTY)
- memset(&p->data[i], 0, sizeof(p->data[0]));
+ malloc_set(&p->data[i], 0, sizeof(p->data[0]));
return 1;
}
diff --git a/src/map/path.c b/src/map/path.c
index 8db44feb6..d0f79c3c3 100644
--- a/src/map/path.c
+++ b/src/map/path.c
@@ -9,6 +9,7 @@
#include "battle.h"
#include "../common/nullpo.h"
#include "../common/showmsg.h"
+#include "../common/malloc.h"
#ifdef MEMWATCH
#include "memwatch.h"
@@ -369,7 +370,7 @@ int path_search_real(struct walkpath_data *wpd,int m,int x0,int y0,int x1,int y1
if(flag&1)
return -1;
- memset(tp,0,sizeof(tp));
+ malloc_set(tp,0,sizeof(tp));
i=calc_index(x0,y0);
tp[i].x=x0;
diff --git a/src/map/pc.c b/src/map/pc.c
index 2c78d3370..bde039c83 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -1133,7 +1133,7 @@ static int pc_bonus_autospell_del(struct s_autospell *spell, int max, short id,
rate-= spell[i].rate;
spell[i].rate = 0;
memmove(&spell[i], &spell[j], sizeof(struct s_autospell));
- memset(&spell[j], 0, sizeof(struct s_autospell));
+ malloc_set(&spell[j], 0, sizeof(struct s_autospell));
j--;
} else {
spell[i].rate -= rate;
@@ -2688,7 +2688,7 @@ int pc_delitem(struct map_session_data *sd,int n,int amount,int type)
if(sd->status.inventory[n].amount<=0){
if(sd->status.inventory[n].equip)
pc_unequipitem(sd,n,3);
- memset(&sd->status.inventory[n],0,sizeof(sd->status.inventory[0]));
+ malloc_set(&sd->status.inventory[n],0,sizeof(sd->status.inventory[0]));
sd->inventory_data[n] = NULL;
}
if(!(type&1))
@@ -3029,7 +3029,7 @@ int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type)
sd->status.cart[n].amount -= amount;
sd->cart_weight -= itemdb_weight(sd->status.cart[n].nameid)*amount ;
if(sd->status.cart[n].amount <= 0){
- memset(&sd->status.cart[n],0,sizeof(sd->status.cart[0]));
+ malloc_set(&sd->status.cart[n],0,sizeof(sd->status.cart[0]));
sd->cart_num--;
}
if(!type) {
@@ -3187,7 +3187,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl)
md->state.steal_flag = UCHAR_MAX; //you can't steal from this mob any more
- memset(&tmp_item,0,sizeof(tmp_item));
+ malloc_set(&tmp_item,0,sizeof(tmp_item));
tmp_item.nameid = itemid;
tmp_item.amount = 1;
tmp_item.identify = itemdb_isidentified(itemid);
@@ -4885,7 +4885,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
/*
if(sd->status.karma > 0) {
int eq_num=0,eq_n[MAX_INVENTORY];
- memset(eq_n,0,sizeof(eq_n));
+ malloc_set(eq_n,0,sizeof(eq_n));
for(i=0;i<MAX_INVENTORY;i++){
int k;
for(k=0;k<MAX_INVENTORY;k++){
@@ -4911,7 +4911,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
|| (battle_config.bone_drop==1 && map[sd->bl.m].flag.pvp))
{
struct item item_tmp;
- memset(&item_tmp,0,sizeof(item_tmp));
+ malloc_set(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid=7420; //PVP Skull item ID
item_tmp.identify=1;
item_tmp.card[0]=CARD0_CREATE;
@@ -4993,7 +4993,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
continue;
if(id == -1){
int eq_num=0,eq_n[MAX_INVENTORY];
- memset(eq_n,0,sizeof(eq_n));
+ malloc_tsetdword(eq_n,0,sizeof(eq_n));
for(i=0;i<MAX_INVENTORY;i++){
int k;
if( (type == 1 && !sd->status.inventory[i].equip)
@@ -5775,7 +5775,7 @@ int pc_setreg(struct map_session_data *sd,int reg,int val)
}
sd->reg_num++;
sd->reg = (struct script_reg *) aRealloc(sd->reg, sizeof(*(sd->reg)) * sd->reg_num);
- memset(sd->reg + (sd->reg_num - 1), 0, sizeof(struct script_reg));
+ malloc_set(sd->reg + (sd->reg_num - 1), 0, sizeof(struct script_reg));
sd->reg[i].index = reg;
sd->reg[i].data = val;
@@ -5825,7 +5825,7 @@ int pc_setregstr(struct map_session_data *sd,int reg,char *str)
ShowFatalError("out of memory : pc_setreg\n");
exit(1);
}
- memset(sd->regstr + (sd->regstr_num - 1), 0, sizeof(struct script_regstr));
+ malloc_set(sd->regstr + (sd->regstr_num - 1), 0, sizeof(struct script_regstr));
sd->regstr[i].index = reg;
strcpy(sd->regstr[i].data, str);
@@ -5953,7 +5953,7 @@ int pc_setregistry(struct map_session_data *sd,char *reg,int val,int type) {
if (strcmp(sd_reg[i].str, reg) == 0) {
if (i != *max - 1)
memcpy(&sd_reg[i], &sd_reg[*max - 1], sizeof(struct global_reg));
- memset(&sd_reg[*max - 1], 0, sizeof(struct global_reg));
+ malloc_tsetdword(&sd_reg[*max - 1], 0, sizeof(struct global_reg));
(*max)--;
sd->state.reg_dirty |= 1<<(type-1); //Mark this registry as "need to be saved"
break;
@@ -5972,7 +5972,7 @@ int pc_setregistry(struct map_session_data *sd,char *reg,int val,int type) {
// add value if not found
if (i < regmax) {
- memset(&sd_reg[i], 0, sizeof(struct global_reg));
+ malloc_tsetdword(&sd_reg[i], 0, sizeof(struct global_reg));
strncpy(sd_reg[i].str, reg, 32);
sprintf(sd_reg[i].value, "%d", val);
(*max)++;
@@ -6028,7 +6028,7 @@ int pc_setregistry_str(struct map_session_data *sd,char *reg,char *val,int type)
if (strcmp(sd_reg[i].str, reg) == 0) {
if (i != *max - 1)
memcpy(&sd_reg[i], &sd_reg[*max - 1], sizeof(struct global_reg));
- memset(&sd_reg[*max - 1], 0, sizeof(struct global_reg));
+ malloc_tsetdword(&sd_reg[*max - 1], 0, sizeof(struct global_reg));
(*max)--;
sd->state.reg_dirty |= 1<<(type-1); //Mark this registry as "need to be saved"
if (type!=3) intif_saveregistry(sd,type);
@@ -6049,7 +6049,7 @@ int pc_setregistry_str(struct map_session_data *sd,char *reg,char *val,int type)
// add value if not found
if (i < regmax) {
- memset(&sd_reg[i], 0, sizeof(struct global_reg));
+ malloc_tsetdword(&sd_reg[i], 0, sizeof(struct global_reg));
strncpy(sd_reg[i].str, reg, 32);
strncpy(sd_reg[i].value, val, 256);
(*max)++;
@@ -6482,7 +6482,7 @@ int pc_checkitem(struct map_session_data *sd)
j++;
}
if(j < MAX_INVENTORY)
- memset(&sd->status.inventory[j],0,sizeof(struct item)*(MAX_INVENTORY-j));
+ malloc_set(&sd->status.inventory[j],0,sizeof(struct item)*(MAX_INVENTORY-j));
for(k=j;k<MAX_INVENTORY;k++)
sd->inventory_data[k] = NULL;
@@ -6502,7 +6502,7 @@ int pc_checkitem(struct map_session_data *sd)
j++;
}
if(j < MAX_CART)
- memset(&sd->status.cart[j],0,sizeof(struct item)*(MAX_CART-j));
+ malloc_set(&sd->status.cart[j],0,sizeof(struct item)*(MAX_CART-j));
// ? 備位置チェック
@@ -7021,8 +7021,8 @@ int pc_readdb(void)
char line[24000],*p;
// 必要??値?み?み
- memset(exp_table,0,sizeof(exp_table));
- memset(max_level,0,sizeof(max_level));
+ malloc_tsetword(exp_table,0,sizeof(exp_table));
+ malloc_tsetword(max_level,0,sizeof(max_level));
sprintf(line, "%s/exp.txt", db_path);
fp=fopen(line, "r");
if(fp==NULL){
@@ -7095,7 +7095,7 @@ int pc_readdb(void)
ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n","exp.txt");
// スキルツリ?
- memset(skill_tree,0,sizeof(skill_tree));
+ malloc_set(skill_tree,0,sizeof(skill_tree));
sprintf(line, "%s/skill_tree.txt", db_path);
fp=fopen(line,"r");
if(fp==NULL){
@@ -7189,7 +7189,7 @@ int pc_readdb(void)
ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n","attr_fix.txt");
// スキルツリ?
- memset(statp,0,sizeof(statp));
+ malloc_set(statp,0,sizeof(statp));
i=1;
j=45; // base points
sprintf(line, "%s/statpoint.txt", db_path);
@@ -7225,7 +7225,7 @@ int pc_read_motd(void) {
FILE *fp;
int ln=0,i=0;
- memset(motd_text,0,sizeof(motd_text));
+ malloc_set(motd_text,0,sizeof(motd_text));
if ((fp = fopen(motd_txt, "r")) != NULL) {
while ((ln < MOTD_LINE_SIZE) && fgets(motd_text[ln], sizeof(motd_text[ln])-1, fp) != NULL) {
if(motd_text[ln][0] == '/' && motd_text[ln][1] == '/')
diff --git a/src/map/pet.c b/src/map/pet.c
index b54f5cf6f..cf5266047 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -343,7 +343,7 @@ static int pet_return_egg(struct map_session_data *sd, struct pet_data *pd)
int flag;
pet_lootitem_drop(pd,sd);
- memset(&tmp_item,0,sizeof(tmp_item));
+ malloc_set(&tmp_item,0,sizeof(tmp_item));
tmp_item.nameid = pd->petDB->EggID;
tmp_item.identify = 1;
tmp_item.card[0] = CARD0_PET;
@@ -633,7 +633,7 @@ int pet_get_egg(int account_id,int pet_id,int flag)
return 0;
}
- memset(&tmp_item,0,sizeof(tmp_item));
+ malloc_set(&tmp_item,0,sizeof(tmp_item));
tmp_item.nameid = pet_db[i].EggID;
tmp_item.identify = 1;
tmp_item.card[0] = CARD0_PET;
@@ -761,7 +761,7 @@ static int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd)
pd->pet.equip = 0;
status_set_viewdata(&pd->bl, pd->pet.class_);
clif_pet_equip(pd);
- memset(&tmp_item,0,sizeof(tmp_item));
+ malloc_set(&tmp_item,0,sizeof(tmp_item));
tmp_item.nameid = nameid;
tmp_item.identify = 1;
if((flag = pc_additem(sd,&tmp_item,1))) {
@@ -1080,7 +1080,7 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd)
}
}
//The smart thing to do is use pd->loot->max (thanks for pointing it out, Shinomori)
- memset(pd->loot->item,0,pd->loot->max * sizeof(struct item));
+ malloc_set(pd->loot->item,0,pd->loot->max * sizeof(struct item));
pd->loot->count = 0;
pd->loot->weight = 0;
pd->ud.canact_tick = gettick()+10000; // 10*1000msの間拾わない
@@ -1278,7 +1278,7 @@ int read_petdb()
pet_db[j].script = NULL;
}
j = 0;
- memset(pet_db,0,sizeof(pet_db));
+ malloc_set(pet_db,0,sizeof(pet_db));
for(i=0;i<2;i++){
sprintf(line, "%s/%s", db_path, filename[i]);
fp=fopen(line,"r");
@@ -1354,7 +1354,7 @@ int read_petdb()
*/
int do_init_pet(void)
{
- memset(pet_db,0,sizeof(pet_db));
+ malloc_set(pet_db,0,sizeof(pet_db));
read_petdb();
item_drop_ers = ers_new((uint32)sizeof(struct item_drop));
diff --git a/src/map/script.c b/src/map/script.c
index 90723cc60..419ea5969 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -307,12 +307,12 @@ int add_str(const unsigned char *p)
if(str_num>=str_data_size){
str_data_size+=128;
str_data=aRealloc(str_data,sizeof(str_data[0])*str_data_size);
- memset(str_data + (str_data_size - 128), '\0', 128);
+ malloc_tsetdword(str_data + (str_data_size - 128), '\0', 128);
}
while(str_pos+(int)strlen((char *) p)+1>=str_size){
str_size+=256;
str_buf=(char *)aRealloc(str_buf,str_size);
- memset(str_buf + (str_size - 256), '\0', 256);
+ malloc_tsetdword(str_buf + (str_size - 256), '\0', 256);
}
strcpy(str_buf+str_pos, (char *) p);
str_data[str_num].type=C_NOP;
@@ -335,7 +335,7 @@ static void check_script_buf(int size)
if(script_pos+size>=script_size){
script_size+=SCRIPT_BLOCK_SIZE;
script_buf=(unsigned char *)aRealloc(script_buf,script_size);
- memset(script_buf + script_size - SCRIPT_BLOCK_SIZE, '\0',
+ malloc_tsetdword(script_buf + script_size - SCRIPT_BLOCK_SIZE, '\0',
SCRIPT_BLOCK_SIZE);
}
}
@@ -1575,7 +1575,7 @@ struct script_code* parse_script(unsigned char *src,const char *file,int line)
struct script_code *code;
static int first=1;
- memset(&syntax,0,sizeof(syntax));
+ malloc_set(&syntax,0,sizeof(syntax));
if(first){
add_buildin_func();
read_constdb();
@@ -1967,7 +1967,7 @@ void push_val(struct script_stack *stack,int type,int val)
stack->sp_max += 64;
stack->stack_data = (struct script_data *)aRealloc(stack->stack_data,
sizeof(stack->stack_data[0]) * stack->sp_max);
- memset(stack->stack_data + (stack->sp_max - 64), 0,
+ malloc_tsetdword(stack->stack_data + (stack->sp_max - 64), 0,
64 * sizeof(*(stack->stack_data)));
}
// if(battle_config.etc_log)
@@ -1998,7 +1998,7 @@ void push_str(struct script_stack *stack,int type,unsigned char *str)
stack->sp_max += 64;
stack->stack_data = (struct script_data *)aRealloc(stack->stack_data,
sizeof(stack->stack_data[0]) * stack->sp_max);
- memset(stack->stack_data + (stack->sp_max - 64), '\0',
+ malloc_tsetdword(stack->stack_data + (stack->sp_max - 64), '\0',
64 * sizeof(*(stack->stack_data)));
}
// if(battle_config.etc_log)
@@ -3149,7 +3149,7 @@ int script_config_read_sub(char *cfgName)
int script_config_read(char *cfgName)
{ //Script related variables should be initialized once! [Skotlex]
- memset (&script_config, 0, sizeof(script_config));
+ malloc_set (&script_config, 0, sizeof(script_config));
script_config.verbose_mode = 0;
script_config.warn_func_no_comma = 1;
script_config.warn_cmd_no_comma = 1;
@@ -5136,7 +5136,7 @@ int buildin_getitem(struct script_state *st)
return 1; //No item created.
}
- memset(&item_tmp,0,sizeof(item_tmp));
+ malloc_set(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid=nameid;
if(!flag)
item_tmp.identify=1;
@@ -5207,7 +5207,7 @@ int buildin_getitem2(struct script_state *st)
}
if(nameid > 0) {
- memset(&item_tmp,0,sizeof(item_tmp));
+ malloc_set(&item_tmp,0,sizeof(item_tmp));
item_data=itemdb_exists(nameid);
if (item_data == NULL)
return -1;
@@ -5301,7 +5301,7 @@ int buildin_getnameditem(struct script_state *st)
return 0;
}
- memset(&item_tmp,0,sizeof(item_tmp));
+ malloc_set(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid=nameid;
item_tmp.amount=1;
item_tmp.identify=1;
@@ -5378,7 +5378,7 @@ int buildin_makeitem(struct script_state *st)
}
if(nameid > 0) {
- memset(&item_tmp,0,sizeof(item_tmp));
+ malloc_set(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid=nameid;
if(!flag)
item_tmp.identify=1;
@@ -10023,7 +10023,7 @@ int buildin_atcommand(struct script_state *st)
else { //Use a dummy character.
struct map_session_data dummy_sd;
struct block_list *bl = NULL;
- memset(&dummy_sd, 0, sizeof(struct map_session_data));
+ malloc_set(&dummy_sd, 0, sizeof(struct map_session_data));
if (st->oid) bl = map_id2bl(st->oid);
if (bl) {
memcpy(&dummy_sd.bl, bl, sizeof(struct block_list));
@@ -10050,7 +10050,7 @@ int buildin_charcommand(struct script_state *st)
else { //Use a dummy character.
struct map_session_data dummy_sd;
struct block_list *bl = NULL;
- memset(&dummy_sd, 0, sizeof(struct map_session_data));
+ malloc_set(&dummy_sd, 0, sizeof(struct map_session_data));
if (st->oid) bl = map_id2bl(st->oid);
if (bl) {
memcpy(&dummy_sd.bl, bl, sizeof(struct block_list));
@@ -10528,7 +10528,7 @@ int buildin_getmapxy(struct script_state *st){
int x,y,type;
char mapname[MAP_NAME_LENGTH+1];
- memset(mapname, 0, sizeof(mapname));
+ malloc_set(mapname, 0, sizeof(mapname));
if( st->stack->stack_data[st->start+2].type!=C_NAME ){
ShowWarning("script: buildin_getmapxy: not mapname variable\n");
@@ -11253,7 +11253,7 @@ int buildin_query_sql(struct script_state *st) {
return 1;
}
- memset(row, 0, sizeof(row));
+ malloc_set(row, 0, sizeof(row));
// Verify argument types
for(j=0; j < nb_rows; j++)
{
@@ -11429,7 +11429,7 @@ int buildin_npcshopitem(struct script_state *st)
sizeof(nd->u.shop_item[0]) * amount);
// Reset sell list.
- memset(nd->u.shop_item, 0, sizeof(nd->u.shop_item[0]) * amount);
+ malloc_set(nd->u.shop_item, 0, sizeof(nd->u.shop_item[0]) * amount);
n = 0;
diff --git a/src/map/skill.c b/src/map/skill.c
index fc8d29068..c8526160e 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -4398,8 +4398,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
struct item item_tmp;
struct block_list tbl;
clif_skill_nodamage(src,bl,skillid,skilllv,1);
- memset(&item_tmp,0,sizeof(item_tmp));
- memset(&tbl,0,sizeof(tbl)); // [MouseJstr]
+ malloc_set(&item_tmp,0,sizeof(item_tmp));
+ malloc_set(&tbl,0,sizeof(tbl)); // [MouseJstr]
item_tmp.nameid = 7049;
item_tmp.identify = 1;
tbl.id = 0;
@@ -5029,7 +5029,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
if(battle_config.skill_removetrap_type){
for(i=0;i<10;i++) {
if(skill_db[su->group->skill_id].itemid[i] > 0){
- memset(&item_tmp,0,sizeof(item_tmp));
+ malloc_set(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid = skill_db[su->group->skill_id].itemid[i];
item_tmp.identify = 1;
if(item_tmp.nameid && (flag=pc_additem(sd,&item_tmp,skill_db[su->group->skill_id].amount[i]))){
@@ -5039,7 +5039,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
}
}
}else{
- memset(&item_tmp,0,sizeof(item_tmp));
+ malloc_set(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid = 1065;
item_tmp.identify = 1;
if(item_tmp.nameid && (flag=pc_additem(sd,&item_tmp,1))){
@@ -7744,7 +7744,7 @@ int skill_check_pc_partner (struct map_session_data *sd, int skill_id, int* skil
}
//Else: new search for partners.
c = 0;
- memset (p_sd, 0, sizeof(p_sd));
+ malloc_tsetdword (p_sd, 0, sizeof(p_sd));
i = map_foreachinrange(skill_check_condition_char_sub, &sd->bl,
range, BL_PC, &sd->bl, &c, &p_sd, skill_id);
@@ -9987,7 +9987,7 @@ int skill_unit_timer_sub (struct block_list *bl, va_list ap)
if(src && src->type==BL_PC && !group->state.into_abyss)
{ //Avoid generating trap items when it did not cost to create them. [Skotlex]
struct item item_tmp;
- memset(&item_tmp,0,sizeof(item_tmp));
+ malloc_set(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid=1065;
item_tmp.identify=1;
map_addflooritem(&item_tmp,1,bl->m,bl->x,bl->y,NULL,NULL,NULL,0);
@@ -10163,7 +10163,7 @@ int skill_unit_move (struct block_list *bl, unsigned int tick, int flag)
if (flag&2 && !(flag&1))
{ //Onout, clear data
- memset (&skill_unit_temp,0,sizeof(skill_unit_temp));
+ malloc_tsetdword (&skill_unit_temp,0,sizeof(skill_unit_temp));
skill_unit_index=0;
}
@@ -10528,7 +10528,7 @@ int skill_produce_mix (struct map_session_data *sd, int skill_id, int nameid, in
if(rand()%10000 < make_per || qty > 1){ //Success, or crafting multiple items.
struct item tmp_item;
- memset(&tmp_item,0,sizeof(tmp_item));
+ malloc_set(&tmp_item,0,sizeof(tmp_item));
tmp_item.nameid=nameid;
tmp_item.amount=1;
tmp_item.identify=1;
@@ -10696,7 +10696,7 @@ int skill_arrow_create (struct map_session_data *sd, int nameid)
pc_delitem(sd,j,1,0);
for(i=0;i<5;i++) {
- memset(&tmp_item,0,sizeof(tmp_item));
+ malloc_set(&tmp_item,0,sizeof(tmp_item));
tmp_item.identify = 1;
tmp_item.nameid = skill_arrow_db[index].cre_id[i];
tmp_item.amount = skill_arrow_db[index].cre_amount[i];
@@ -10845,7 +10845,7 @@ void skill_init_unit_layout (void)
{
int i,j,size,pos = 0;
- memset(skill_unit_layout,0,sizeof(skill_unit_layout));
+ malloc_set(skill_unit_layout,0,sizeof(skill_unit_layout));
for (i=0; i<=MAX_SQUARE_LAYOUT; i++) {
size = i*2+1;
skill_unit_layout[i].count = size*size;
@@ -11081,7 +11081,7 @@ int skill_readdb (void)
char line[1024],path[1024],*p;
char *filename[]={"produce_db.txt","produce_db2.txt"};
- memset(skill_db,0,sizeof(skill_db));
+ malloc_set(skill_db,0,sizeof(skill_db));
sprintf(path, "%s/skill_db.txt", db_path);
fp=fopen(path,"r");
if(fp==NULL){
@@ -11236,7 +11236,7 @@ int skill_readdb (void)
while(fgets(line,1020,fp)){
char *split[50];
l++;
- memset(split,0,sizeof(split)); // [Valaris] thanks to fov
+ malloc_tsetdword(split,0,sizeof(split)); // [Valaris] thanks to fov
if(line[0]=='/' && line[1]=='/')
continue;
j = skill_split_str(line,split,6);
@@ -11321,7 +11321,7 @@ int skill_readdb (void)
ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n",path);
skill_init_unit_layout();
- memset(skill_produce_db,0,sizeof(skill_produce_db));
+ malloc_set(skill_produce_db,0,sizeof(skill_produce_db));
for(m=0;m<2;m++){
sprintf(path, "%s/%s", db_path, filename[m]);
fp=fopen(path,"r");
@@ -11337,7 +11337,7 @@ int skill_readdb (void)
int x,y;
if(line[0]=='/' && line[1]=='/')
continue;
- memset(split,0,sizeof(split));
+ malloc_tsetdword(split,0,sizeof(split));
j = skill_split_str(line,split,(3 + MAX_PRODUCE_RESOURCE * 2));
if(split[0]==0) //fixed by Lupus
continue;
@@ -11360,7 +11360,7 @@ int skill_readdb (void)
ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",k,path);
}
- memset(skill_arrow_db,0,sizeof(skill_arrow_db));
+ malloc_set(skill_arrow_db,0,sizeof(skill_arrow_db));
sprintf(path, "%s/create_arrow_db.txt", db_path);
fp=fopen(path,"r");
@@ -11374,7 +11374,7 @@ int skill_readdb (void)
int x,y;
if(line[0]=='/' && line[1]=='/')
continue;
- memset(split,0,sizeof(split));
+ malloc_tsetdword(split,0,sizeof(split));
j = skill_split_str(line,split,13);
if(split[0]==0) //fixed by Lupus
continue;
@@ -11395,7 +11395,7 @@ int skill_readdb (void)
fclose(fp);
ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",k,path);
- memset(skill_abra_db,0,sizeof(skill_abra_db));
+ malloc_set(skill_abra_db,0,sizeof(skill_abra_db));
sprintf(path, "%s/abra_db.txt", db_path);
fp=fopen(path,"r");
if(fp==NULL){
@@ -11407,7 +11407,7 @@ int skill_readdb (void)
char *split[16];
if(line[0]=='/' && line[1]=='/')
continue;
- memset(split,0,sizeof(split));
+ malloc_tsetdword(split,0,sizeof(split));
j = skill_split_str(line,split,13);
if(split[0]==0) //fixed by Lupus
continue;
@@ -11435,7 +11435,7 @@ int skill_readdb (void)
char *split[50];
if(line[0]=='/' && line[1]=='/')
continue;
- memset(split,0,sizeof(split));
+ malloc_tsetdword(split,0,sizeof(split));
j = skill_split_str(line,split,3);
if(split[0]==0) //fixed by Lupus
continue;
@@ -11464,7 +11464,7 @@ int skill_readdb (void)
char *split[16];
if(line[0]=='/' && line[1]=='/')
continue;
- memset(split,0,sizeof(split));
+ malloc_tsetdword(split,0,sizeof(split));
j = skill_split_str(line,split,2);
if(split[0]==0) //fixed by Lupus
continue;
diff --git a/src/map/status.c b/src/map/status.c
index 8f8da8098..12a20a335 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -95,8 +95,8 @@ void initChangeTables(void) {
StatusIconChangeTable[i] = SI_BLANK;
for (i = 0; i < MAX_SKILL; i++)
SkillStatusChangeTableArray[i] = -1;
- memset(StatusSkillChangeTable, 0, sizeof(StatusSkillChangeTable));
- memset(StatusChangeFlagTable, 0, sizeof(StatusChangeFlagTable));
+ malloc_set(StatusSkillChangeTable, 0, sizeof(StatusSkillChangeTable));
+ malloc_set(StatusChangeFlagTable, 0, sizeof(StatusChangeFlagTable));
//First we define the skill for common ailments. These are used in
//skill_additional_effect through sc cards. [Skotlex]
@@ -471,7 +471,7 @@ int SkillStatusChangeTable(int skill)
}
int StatusIconChangeTable[SC_MAX]; //Stores the icon that should be associated to this status change.
static void initDummyData(void) {
- memset(&dummy_status, 0, sizeof(dummy_status));
+ malloc_set(&dummy_status, 0, sizeof(dummy_status));
dummy_status.hp =
dummy_status.max_hp =
dummy_status.max_sp =
@@ -709,11 +709,11 @@ int status_damage(struct block_list *src,struct block_list *target,int hp, int s
{ //Reset regen ticks.
struct regen_data *regen = status_get_regen_data(target);
if (regen) {
- memset(&regen->tick, 0, sizeof(regen->tick));
+ malloc_set(&regen->tick, 0, sizeof(regen->tick));
if (regen->sregen)
- memset(&regen->sregen->tick, 0, sizeof(regen->sregen->tick));
+ malloc_set(&regen->sregen->tick, 0, sizeof(regen->sregen->tick));
if (regen->ssregen)
- memset(&regen->ssregen->tick, 0, sizeof(regen->ssregen->tick));
+ malloc_set(&regen->ssregen->tick, 0, sizeof(regen->ssregen->tick));
}
}
if(flag&4) //Delete from memory. (also invokes map removal code)
@@ -1559,7 +1559,7 @@ int status_calc_pc(struct map_session_data* sd,int first)
// zeroed arays, order follows the order in map.h.
// add new arrays to the end of zeroed area in map.h (see comments) and size here. [zzo]
- memset (sd->param_bonus, 0, sizeof(sd->param_bonus)
+ malloc_set (sd->param_bonus, 0, sizeof(sd->param_bonus)
+ sizeof(sd->param_equip)
+ sizeof(sd->subele)
+ sizeof(sd->subrace)
@@ -1582,12 +1582,12 @@ int status_calc_pc(struct map_session_data* sd,int first)
+ sizeof(sd->sp_gain_race)
);
- memset (&sd->right_weapon.overrefine, 0, sizeof(sd->right_weapon) - sizeof(sd->right_weapon.atkmods));
- memset (&sd->left_weapon.overrefine, 0, sizeof(sd->left_weapon) - sizeof(sd->left_weapon.atkmods));
+ malloc_set (&sd->right_weapon.overrefine, 0, sizeof(sd->right_weapon) - sizeof(sd->right_weapon.atkmods));
+ malloc_set (&sd->left_weapon.overrefine, 0, sizeof(sd->left_weapon) - sizeof(sd->left_weapon.atkmods));
- memset(&sd->special_state,0,sizeof(sd->special_state));
- memset(&status->max_hp, 0, sizeof(struct status_data)-(sizeof(status->hp)+sizeof(status->sp)+sizeof(status->lhw)));
- memset(status->lhw, 0, sizeof(struct weapon_atk));
+ malloc_set(&sd->special_state,0,sizeof(sd->special_state));
+ malloc_set(&status->max_hp, 0, sizeof(struct status_data)-(sizeof(status->hp)+sizeof(status->sp)+sizeof(status->lhw)));
+ malloc_set(status->lhw, 0, sizeof(struct weapon_atk));
//FIXME: Most of these stuff should be calculated once, but how do I fix the memset above to do that? [Skotlex]
status->speed = DEFAULT_WALK_SPEED;
@@ -1606,7 +1606,7 @@ int status_calc_pc(struct map_session_data* sd,int first)
status->race = RC_DEMIHUMAN;
//zero up structures...
- memset(&sd->autospell,0,sizeof(sd->autospell)
+ malloc_set(&sd->autospell,0,sizeof(sd->autospell)
+ sizeof(sd->autospell2)
+ sizeof(sd->addeff)
+ sizeof(sd->addeff2)
@@ -1621,7 +1621,7 @@ int status_calc_pc(struct map_session_data* sd,int first)
);
// vars zeroing. ints, shorts, chars. in that order.
- memset (&sd->arrow_atk, 0,sizeof(sd->arrow_atk)
+ malloc_set (&sd->arrow_atk, 0,sizeof(sd->arrow_atk)
+ sizeof(sd->arrow_ele)
+ sizeof(sd->arrow_cri)
+ sizeof(sd->arrow_hit)
@@ -1764,7 +1764,7 @@ int status_calc_pc(struct map_session_data* sd,int first)
//Store equipment script bonuses
memcpy(sd->param_equip,sd->param_bonus,sizeof(sd->param_equip));
- memset(sd->param_bonus, 0, sizeof(sd->param_bonus));
+ malloc_set(sd->param_bonus, 0, sizeof(sd->param_bonus));
status->def += (refinedef+50)/100;
@@ -4226,7 +4226,7 @@ void status_change_init(struct block_list *bl)
struct status_change *sc = status_get_sc(bl);
int i;
nullpo_retv(sc);
- memset(sc, 0, sizeof (struct status_change));
+ malloc_set(sc, 0, sizeof (struct status_change));
for (i=0; i< SC_MAX; i++)
sc->data[i].timer = -1;
}
@@ -7018,7 +7018,7 @@ static int status_calc_sigma(void)
unsigned int k;
for(i=0;i<MAX_PC_CLASS;i++) {
- memset(hp_sigma_val[i],0,sizeof(hp_sigma_val[i]));
+ malloc_tsetdword(hp_sigma_val[i],0,sizeof(hp_sigma_val[i]));
for(k=0,j=2;j<=MAX_LEVEL;j++) {
k += hp_coefficient[i]*j + 50;
k -= k%100;
@@ -7072,7 +7072,7 @@ int status_readdb(void) {
fclose(fp);
ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n",path);
- memset(job_bonus,0,sizeof(job_bonus)); // Job-specific stats bonus
+ malloc_tsetdword(job_bonus,0,sizeof(job_bonus)); // Job-specific stats bonus
sprintf(path, "%s/job_db2.txt", db_path);
fp=fopen(path,"r");
if(fp==NULL){
@@ -7113,7 +7113,7 @@ int status_readdb(void) {
continue;
if(atoi(line)<=0)
continue;
- memset(split,0,sizeof(split));
+ malloc_tsetdword(split,0,sizeof(split));
for(j=0,p=line;j<MAX_WEAPON_TYPE && p;j++){
split[j]=p;
p=strchr(p,',');
@@ -7148,7 +7148,7 @@ int status_readdb(void) {
continue;
if(atoi(line)<=0)
continue;
- memset(split,0,sizeof(split));
+ malloc_tsetdword(split,0,sizeof(split));
for(j=0,p=line;j<MAX_REFINE+4 && p;j++){
split[j]=p;
p=strchr(p,',');
diff --git a/src/map/storage.c b/src/map/storage.c
index bf018dc90..6f504eab3 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -218,7 +218,7 @@ static int storage_delitem(struct map_session_data *sd,struct storage *stor,int
stor->storage_[n].amount-=amount;
if(stor->storage_[n].amount==0){
- memset(&stor->storage_[n],0,sizeof(stor->storage_[0]));
+ malloc_set(&stor->storage_[n],0,sizeof(stor->storage_[0]));
stor->storage_amount--;
clif_updatestorageamount(sd,stor);
}
@@ -566,7 +566,7 @@ int guild_storage_delitem(struct map_session_data *sd,struct guild_storage *stor
stor->storage_[n].amount-=amount;
if(stor->storage_[n].amount==0){
- memset(&stor->storage_[n],0,sizeof(stor->storage_[0]));
+ malloc_set(&stor->storage_[n],0,sizeof(stor->storage_[0]));
stor->storage_amount--;
clif_updateguildstorageamount(sd,stor);
}
diff --git a/src/map/trade.c b/src/map/trade.c
index 6c8675d2b..fe695d695 100644
--- a/src/map/trade.c
+++ b/src/map/trade.c
@@ -17,6 +17,7 @@
#include "intif.h"
#include "atcommand.h"
#include "log.h"
+#include "../common/malloc.h"
/*==========================================
@@ -114,8 +115,8 @@ void trade_tradeack(struct map_session_data *sd, int type) {
if (type == 3) { //Initiate trade
sd->state.trading = 1;
target_sd->state.trading = 1;
- memset(&sd->deal, 0, sizeof(sd->deal));
- memset(&target_sd->deal, 0, sizeof(target_sd->deal));
+ malloc_set(&sd->deal, 0, sizeof(sd->deal));
+ malloc_set(&target_sd->deal, 0, sizeof(target_sd->deal));
clif_tradestart(target_sd, type);
clif_tradestart(sd, type);
if (sd->npc_id)
@@ -152,7 +153,7 @@ int impossible_trade_check(struct map_session_data *sd) {
// remove equiped items (they can not be trade)
for (i = 0; i < MAX_INVENTORY; i++)
if (inventory[i].nameid > 0 && inventory[i].equip && !(inventory[i].equip & EQP_AMMO))
- memset(&inventory[i], 0, sizeof(struct item));
+ malloc_set(&inventory[i], 0, sizeof(struct item));
// check items in player inventory
for(i = 0; i < 10; i++) {
@@ -230,7 +231,7 @@ int trade_check(struct map_session_data *sd, struct map_session_data *tsd) {
inventory[n].amount -= amount;
//let's not make room, as pc_additem is done before pc_delitem, so it could lead to problems depending on order.
// if (!inventory[n].amount)
-// memset(&inventory[n], 0, sizeof(struct item));
+// malloc_set(&inventory[n], 0, sizeof(struct item));
break;
}
}
@@ -243,7 +244,7 @@ int trade_check(struct map_session_data *sd, struct map_session_data *tsd) {
inventory2[i].amount = amount;
inventory[n].amount -= amount;
// if (!inventory[n].amount)
-// memset(&inventory[n], 0, sizeof(struct item));
+// malloc_set(&inventory[n], 0, sizeof(struct item));
}
}
amount = tsd->deal.item[trade_i].amount;
@@ -265,7 +266,7 @@ int trade_check(struct map_session_data *sd, struct map_session_data *tsd) {
inventory[i].amount += amount;
inventory2[n].amount -= amount;
// if (!inventory2[n].amount)
-// memset(&inventory2[n], 0, sizeof(struct item));
+// malloc_set(&inventory2[n], 0, sizeof(struct item));
break;
}
}
@@ -277,7 +278,7 @@ int trade_check(struct map_session_data *sd, struct map_session_data *tsd) {
inventory[i].amount = amount;
inventory2[n].amount -= amount;
// if (!inventory2[n].amount)
-// memset(&inventory2[n], 0, sizeof(struct item));
+// malloc_set(&inventory2[n], 0, sizeof(struct item));
}
}
diff --git a/src/map/unit.c b/src/map/unit.c
index af77ce7f9..13959e5cd 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -1389,7 +1389,7 @@ void unit_dataset(struct block_list *bl) {
struct unit_data *ud;
nullpo_retv(ud = unit_bl2ud(bl));
- memset( ud, 0, sizeof( struct unit_data) );
+ malloc_set( ud, 0, sizeof( struct unit_data) );
ud->bl = bl;
ud->walktimer = -1;
ud->skilltimer = -1;