summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2014-01-12 16:38:58 -0200
committershennetsind <ind@henn.et>2014-01-12 16:38:58 -0200
commite4c21279a33a810ee80c334a74c422affcdab870 (patch)
treea7dab158ca095f82c6814d7c903e222ba90716c6
parentd9c1629c753ae756ce32613a76e69b3a03970b8d (diff)
parent253e90c67f7ddbbb3ab2f9f68a0d760d059ed797 (diff)
downloadhercules-e4c21279a33a810ee80c334a74c422affcdab870.tar.gz
hercules-e4c21279a33a810ee80c334a74c422affcdab870.tar.bz2
hercules-e4c21279a33a810ee80c334a74c422affcdab870.tar.xz
hercules-e4c21279a33a810ee80c334a74c422affcdab870.zip
Merge branch 'master' of https://github.com/HerculesWS/Hercules
-rw-r--r--npc/custom/test.txt118
-rw-r--r--src/char/int_guild.c1
-rw-r--r--src/common/db.h4
-rw-r--r--src/common/mmo.h3
-rw-r--r--src/map/atcommand.c8
-rw-r--r--src/map/chat.c2
-rw-r--r--src/map/clif.c18
-rw-r--r--src/map/guild.c18
-rw-r--r--src/map/intif.c12
-rw-r--r--src/map/npc.h9
-rw-r--r--src/map/npc_chat.c18
-rw-r--r--src/map/script.c48
12 files changed, 179 insertions, 80 deletions
diff --git a/npc/custom/test.txt b/npc/custom/test.txt
index 5d5dcf8e9..b3579d4c3 100644
--- a/npc/custom/test.txt
+++ b/npc/custom/test.txt
@@ -10,14 +10,24 @@
- script HerculesSelfTest -1,{
end;
+
+OnReportError:
+ .@msg$ = getarg(0,"Unknown Error");
+ .@val$ = getarg(1,"");
+ .@ref$ = getarg(2,"");
+ if (.errors == 1)
+ debugmes "**** WARNING: Any self-test results past this point are unreliable because of previous errors. ****";
+ debugmes "Error: "+.@msg$+": '"+.@val$+"' (found) != '"+.@ref$+"' (expected)";
+ .errors++;
+ //end;
+ return;
+
OnCheck:
.@msg$ = getarg(0,"Unknown Error");
.@val = getarg(1,0);
.@ref = getarg(2,1);
if (.@val != .@ref) {
- debugmes "Error: "+.@msg$+": '"+.@val+"' != '"+.@ref+"'";
- .errors++;
- //end;
+ callsub(OnReportError, .@msg$, ""+.@val, ""+.@ref); // String coercion
}
return;
OnCheckStr:
@@ -25,9 +35,7 @@ OnCheckStr:
.@val$ = getarg(1,"");
.@ref$ = getarg(2,"");
if (.@val$ != .@ref$) {
- debugmes "Error: "+.@msg$+": '"+.@val$+"' != '"+.@ref$+"'";
- .errors++;
- //end;
+ callsub(OnReportError, .@msg$, .@val$, .@ref$);
}
return;
OnInit:
@@ -390,9 +398,105 @@ OnInit:
.@x = 3;
callsub(OnCheck, "Dangling else", .@x, 0);
+
+ // Array operations
+ .@x[0] = 1;
+ callsub(OnCheck, "Array size (single value)", getarraysize(.@x), 1);
+ .@x[0] = 0;
+ callsub(OnCheck, "Array size (single value removal)", getarraysize(.@x), 0);
+
+ .@x[0] = 1;
+ .@x[1] = 2;
+ .@x[2] = 3;
+ .@x[5] = 4;
+ .@x[8] = 5;
+ .@x[9] = 0;
+ setarray .@y[0], 1, 2, 3, 0, 0, 4, 0, 0, 5;
+ callsub(OnCheck, "Array size (assignment)", getarraysize(.@x), 9);
+ callsub(OnCheck, "Array size (setarray)", getarraysize(.@y), 9);
+ for (.@i = 0; .@i < 10; ++.@i) {
+ callsub(OnCheck, "Array subscript and setarray [" + .@i + "]", .@x[.@i], .@y[.@i]);
+ }
+
+ cleararray .@x[1], 8, 6;
+ callsub(OnCheck, "cleararray (value) [0]", .@x[0], 1);
+ for (.@i = 1; .@i < 7; ++.@i) {
+ callsub(OnCheck, "cleararray (value) [" + .@i + "]", .@x[.@i], 8);
+ }
+ callsub(OnCheck, "cleararray (value) [7]", .@x[7], 0);
+ callsub(OnCheck, "cleararray (value) [8]", .@x[8], 5);
+ callsub(OnCheck, "cleararray (value) [9]", .@x[9], 0);
+
+ cleararray .@x, 0, getarraysize(.@x);
+ cleararray .@y, 0, getarraysize(.@y);
+ callsub(OnCheck, "cleararray and getarraysize", getarraysize(.@x), 0);
+ for (.@i = 0; .@i < 10; ++.@i) {
+ callsub(OnCheck, "cleararray (zero) [" + .@i + "]", .@x[.@i], 0);
+ }
+
+ cleararray .@x, 0, getarraysize(.@x);
+ setarray .@x[1], 1, 2, 0, 0, 0, 6, 7, 8, 0, 0, 0, 13, 14, 15, 16;
+ deletearray .@x;
+ callsub(OnCheck, "deletearray (clear) and getarraysize", getarraysize(.@x), 0);
+ for (.@i = 0; .@i < 18; ++.@i) {
+ callsub(OnCheck, "deletearray (clear) [" + .@i + "]", .@x[.@i], 0);
+ }
+
+ deletearray .@x;
+ deletearray .@y;
+ setarray .@x[1], 1, 2, 0, 0, 0, 6, 7, 8, 0, 0, 0, 0, 13, 14, 15, 16;
+ setarray .@y, 0, 1, 2, 0, 0, 0, 6, 7, 8, 0, 0, 0, 13, 14, 15, 16;
+ deletearray .@x[9], 1;
+ callsub(OnCheck, "deletearray (single) and getarraysize", getarraysize(.@x), 16);
+ for (.@i = 0; .@i < 18; ++.@i) {
+ callsub(OnCheck, "deletearray (single) [" + .@i + "]", .@x[.@i], .@y[.@i]);
+ }
+
+ deletearray .@x;
+ deletearray .@y;
+ setarray .@x[1], 1, 2, 0, 0, 0, 6, 7, 8, 0, 0, 0, 13, 14, 15, 16;
+ setarray .@y, 0, 1, 6, 7, 8, 0, 0, 0, 13, 14, 15, 16;
+ deletearray .@x[2], 4;
+ callsub(OnCheck, "deletearray (multiple) and getarraysize", getarraysize(.@x), 12);
+ for (.@i = 0; .@i < 18; ++.@i) {
+ callsub(OnCheck, "deletearray (multiple) [" + .@i + "]", .@x[.@i], .@y[.@i]);
+ }
+
+ deletearray .@x;
+ deletearray .@y;
+ setarray .@x[1], 1, 2, 0, 0, 0, 6, 7, 8, 0, 0, 0, 13, 14, 15, 16;
+ setarray .@y, 0, 1;
+ deletearray .@x[2], 1000;
+ callsub(OnCheck, "deletearray (large count) and getarraysize", getarraysize(.@x), 2);
+ for (.@i = 0; .@i < 18; ++.@i) {
+ callsub(OnCheck, "deletearray (large count) [" + .@i + "]", .@x[.@i], .@y[.@i]);
+ }
+
+ deletearray .@x;
+ deletearray .@y;
+ setarray .@x[1], 1, 2, 0, 0, 0, 6, 7, 8, 0, 0, 0, 13, 14, 15, 16;
+ setarray .@y, 0, 1;
+ deletearray .@x[2];
+ callsub(OnCheck, "deletearray (truncate) and getarraysize", getarraysize(.@x), 2);
+ for (.@i = 0; .@i < 18; ++.@i) {
+ callsub(OnCheck, "deletearray (truncate) [" + .@i + "]", .@x[.@i], .@y[.@i]);
+ }
+
+ deletearray .@x;
+ .@x[1] = 2;
+ .@x[65536] = 1;
+ callsub(OnCheck, "large array index", .@x[65536], 1);
+ callsub(OnCheck, "large array index and getarraysize", getarraysize(.@x), 65537);
+ .@x[65536] = 0;
+ callsub(OnCheck, "large array index (shrink)", .@x[65536], 0);
+ callsub(OnCheck, "large array index and getarraysize (shrink)", getarraysize(.@x), 2);
+ .@x[1] = 0;
+ callsub(OnCheck, "array shrink", .@x[1], 0);
+ callsub(OnCheck, "array shrink and getarraysize", getarraysize(.@x), 0);
+
if (.errors) {
debugmes "Script engine self-test [ FAILED ]";
- debugmes "The test was completed with " + .errors + " errors.";
+ debugmes "**** The test was completed with " + .errors + " errors. ****";
} else {
debugmes "Script engine self-test [ PASSED ]";
}
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index 6bd8ca568..427c57531 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -43,7 +43,6 @@ static bool guild_check_empty(struct guild *g);
int guild_calcinfo(struct guild *g);
int mapif_guild_basicinfochanged(int guild_id,int type,const void *data,int len);
int mapif_guild_info(int fd,struct guild *g);
-int guild_break_sub(int key,void *data,va_list ap);
int inter_guild_tosql(struct guild *g,int flag);
static int guild_save_timer(int tid, int64 tick, int id, intptr_t data) {
diff --git a/src/common/db.h b/src/common/db.h
index 9d7bdda10..c00489b93 100644
--- a/src/common/db.h
+++ b/src/common/db.h
@@ -928,8 +928,8 @@ struct linkdb_node {
typedef void (*LinkDBFunc)(void* key, void* data, va_list args);
-void linkdb_insert (struct linkdb_node** head, void *key, void* data); // 重複を考慮しない
-void linkdb_replace (struct linkdb_node** head, void *key, void* data); // 重複を考慮する
+void linkdb_insert (struct linkdb_node** head, void *key, void* data); // Doesn't take into account duplicate keys
+void linkdb_replace (struct linkdb_node** head, void *key, void* data); // Takes into account duplicate keys
void* linkdb_search (struct linkdb_node** head, void *key);
void* linkdb_erase (struct linkdb_node** head, void *key);
void linkdb_final (struct linkdb_node** head);
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 594d1cb26..cb1e52311 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -536,6 +536,7 @@ struct guild_skill {
int id,lv;
};
+struct hChSysCh;
struct guild {
int guild_id;
short guild_lv, connect_member, max_member, average_lv;
@@ -558,7 +559,7 @@ struct guild {
short *instance;
unsigned short instances;
- void *channel;
+ struct hChSysCh *channel;
};
struct guild_castle {
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index d4b6c2382..b2d486520 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -8647,7 +8647,7 @@ ACMD(join) {
} else if( hChSys.ally && sd->status.guild_id && strcmpi(name + 1, hChSys.ally_name) == 0 ) {
struct guild *g = sd->guild;
if( !g ) return false;/* unlikely, but we wont let it crash anyway. */
- channel = (struct hChSysCh *)g->channel;
+ channel = g->channel;
} else if( !( channel = strdb_get(clif->channel_db, name + 1) ) ) {
sprintf(atcmd_output, msg_txt(1400),name,command); // Unknown Channel '%s' (usage: %s <#channel_name>)
clif->message(fd, atcmd_output);
@@ -8691,8 +8691,8 @@ ACMD(join) {
int i;
for (i = 0; i < MAX_GUILDALLIANCE; i++) {
if( g->alliance[i].opposition == 0 && g->alliance[i].guild_id && (sg = guild->search(g->alliance[i].guild_id) ) ) {
- if( !(((struct hChSysCh*)sg->channel)->banned && idb_exists(((struct hChSysCh*)sg->channel)->banned, sd->status.account_id))) {
- clif->chsys_join((struct hChSysCh *)sg->channel,sd);
+ if( !(sg->channel->banned && idb_exists(sg->channel->banned, sd->status.account_id))) {
+ clif->chsys_join(sg->channel,sd);
}
}
}
@@ -8822,7 +8822,7 @@ ACMD(channel) {
if( hChSys.ally && sd->status.guild_id ) {
struct guild *g = sd->guild;
if( !g ) { dbi_destroy(iter); return false; }
- sprintf(atcmd_output, msg_txt(1409), hChSys.ally_name, db_size(((struct hChSysCh *)g->channel)->users));// - #%s ( %d users )
+ sprintf(atcmd_output, msg_txt(1409), hChSys.ally_name, db_size(g->channel->users));// - #%s ( %d users )
clif->message(fd, atcmd_output);
}
for(channel = dbi_first(iter); dbi_exists(iter); channel = dbi_next(iter)) {
diff --git a/src/map/chat.c b/src/map/chat.c
index 52d7f246a..50fe2aeb5 100644
--- a/src/map/chat.c
+++ b/src/map/chat.c
@@ -318,7 +318,7 @@ int chat_kickchat(struct map_session_data* sd, const char* kickusername) {
if (pc_has_permission(cd->usersd[i], PC_PERM_NO_CHAT_KICK))
return 0; //gm kick protection [Valaris]
- idb_put(cd->kick_list,cd->usersd[i]->status.char_id,(void*)1);
+ idb_iput(cd->kick_list,cd->usersd[i]->status.char_id,1);
chat->leave(cd->usersd[i],1);
return 0;
diff --git a/src/map/clif.c b/src/map/clif.c
index 5f61bafad..77d4d20d8 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -10387,7 +10387,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
} else if( hChSys.ally && sd->status.guild_id && strcmpi(chname, hChSys.ally_name) == 0 ) {
struct guild *g = sd->guild;
if( !g ) return;
- channel = (struct hChSysCh *)g->channel;
+ channel = g->channel;
}
if( channel || (channel = strdb_get(clif->channel_db,chname)) ) {
int k;
@@ -10402,8 +10402,8 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
struct guild *g = sd->guild, *sg = NULL;
for (k = 0; k < MAX_GUILDALLIANCE; k++) {
if( g->alliance[k].opposition == 0 && g->alliance[k].guild_id && (sg = guild->search(g->alliance[k].guild_id) ) ) {
- if( !(((struct hChSysCh*)sg->channel)->banned && idb_exists(((struct hChSysCh*)sg->channel)->banned, sd->status.account_id)))
- clif->chsys_join((struct hChSysCh *)sg->channel,sd);
+ if( !(sg->channel->banned && idb_exists(sg->channel->banned, sd->status.account_id)))
+ clif->chsys_join(sg->channel,sd);
}
}
}
@@ -10683,19 +10683,19 @@ void clif_hercules_chsys_gjoin(struct guild *g1,struct guild *g2) {
struct hChSysCh *channel;
int j;
- if( (channel = (struct hChSysCh*)g1->channel) ) {
+ if( (channel = g1->channel) ) {
for(j = 0; j < g2->max_member; j++) {
if( (sd = g2->member[j].sd) != NULL ) {
- if( !(((struct hChSysCh*)g1->channel)->banned && idb_exists(((struct hChSysCh*)g1->channel)->banned, sd->status.account_id)))
+ if( !(g1->channel->banned && idb_exists(g1->channel->banned, sd->status.account_id)))
clif->chsys_join(channel,sd);
}
}
}
- if( (channel = (struct hChSysCh*)g2->channel) ) {
+ if( (channel = g2->channel) ) {
for(j = 0; j < g1->max_member; j++) {
if( (sd = g1->member[j].sd) != NULL ) {
- if( !(((struct hChSysCh*)g2->channel)->banned && idb_exists(((struct hChSysCh*)g2->channel)->banned, sd->status.account_id)))
+ if( !(g2->channel->banned && idb_exists(g2->channel->banned, sd->status.account_id)))
clif->chsys_join(channel,sd);
}
}
@@ -10706,7 +10706,7 @@ void clif_hercules_chsys_gleave(struct guild *g1,struct guild *g2) {
struct hChSysCh *channel;
int j;
- if( (channel = (struct hChSysCh*)g1->channel) ) {
+ if( (channel = g1->channel) ) {
for(j = 0; j < g2->max_member; j++) {
if( (sd = g2->member[j].sd) != NULL ) {
clif->chsys_left(channel,sd);
@@ -10714,7 +10714,7 @@ void clif_hercules_chsys_gleave(struct guild *g1,struct guild *g2) {
}
}
- if( (channel = (struct hChSysCh*)g2->channel) ) {
+ if( (channel = g2->channel) ) {
for(j = 0; j < g1->max_member; j++) {
if( (sd = g1->member[j].sd) != NULL ) {
clif->chsys_left(channel,sd);
diff --git a/src/map/guild.c b/src/map/guild.c
index 8a34b7f4b..909c360a8 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -454,7 +454,7 @@ int guild_recv_info(struct guild *sg) {
DBData data;
struct map_session_data *sd;
bool guild_new = false;
- void *aChSysSave = NULL;
+ struct hChSysCh *aChSysSave = NULL;
nullpo_ret(sg);
@@ -494,8 +494,8 @@ int guild_recv_info(struct guild *sg) {
if( sg->alliance[i].guild_id == sd->status.guild_id ) {
clif->chsys_join(channel,sd);
} else if( tg[i] != NULL ) {
- if( !(((struct hChSysCh*)tg[i]->channel)->banned && idb_exists(((struct hChSysCh*)tg[i]->channel)->banned, sd->status.account_id)))
- clif->chsys_join((struct hChSysCh*)tg[i]->channel,sd);
+ if( !(tg[i]->channel->banned && idb_exists(tg[i]->channel->banned, sd->status.account_id)))
+ clif->chsys_join(tg[i]->channel,sd);
}
}
}
@@ -506,7 +506,7 @@ int guild_recv_info(struct guild *sg) {
}
- aChSysSave = (void*)channel;
+ aChSysSave = channel;
}
before=*sg;
@@ -725,14 +725,14 @@ void guild_member_joined(struct map_session_data *sd)
if( hChSys.ally && hChSys.ally_autojoin ) {
struct guild* sg = NULL;
- struct hChSysCh *channel = (struct hChSysCh*)g->channel;
+ struct hChSysCh *channel = g->channel;
if( !(channel->banned && idb_exists(channel->banned, sd->status.account_id) ) )
clif->chsys_join(channel,sd);
for (i = 0; i < MAX_GUILDALLIANCE; i++) {
if( g->alliance[i].opposition == 0 && g->alliance[i].guild_id && (sg = guild->search(g->alliance[i].guild_id) ) ) {
- if( !(((struct hChSysCh*)sg->channel)->banned && idb_exists(((struct hChSysCh*)sg->channel)->banned, sd->status.account_id)))
- clif->chsys_join((struct hChSysCh*)sg->channel,sd);
+ if( !(sg->channel->banned && idb_exists(sg->channel->banned, sd->status.account_id)))
+ clif->chsys_join(sg->channel,sd);
}
}
}
@@ -1753,7 +1753,7 @@ int guild_broken(int guild_id,int flag)
gstorage->delete(guild_id);
if( hChSys.ally ) {
if( g->channel != NULL ) {
- clif->chsys_delete(( struct hChSysCh * )g->channel);
+ clif->chsys_delete(g->channel);
}
}
if( g->instance )
@@ -2231,7 +2231,7 @@ void do_final_guild(void) {
for( g = dbi_first(iter); dbi_exists(iter); g = dbi_next(iter) ) {
if( g->channel != NULL )
- clif->chsys_delete((struct hChSysCh *)g->channel);
+ clif->chsys_delete(g->channel);
if( g->instance != NULL ) {
aFree(g->instance);
g->instance = NULL;
diff --git a/src/map/intif.c b/src/map/intif.c
index 9d447b9c0..49fbe4721 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -288,7 +288,7 @@ int intif_saveregistry(struct map_session_data *sd) {
iter = db_iterator(sd->var_db);
for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
const char *varname = NULL;
- void *src = NULL;
+ struct script_reg_state *src = NULL;
if( data->type != DB_DATA_PTR ) /* its a @number */
continue;
@@ -301,10 +301,10 @@ int intif_saveregistry(struct map_session_data *sd) {
src = DB->data2ptr(data);
/* no need! */
- if( !((struct script_reg_state*)src)->update )
+ if( !src->update )
continue;
- ((struct script_reg_state*)src)->update = false;
+ src->update = false;
len = strlen(varname)+1;
@@ -317,8 +317,8 @@ int intif_saveregistry(struct map_session_data *sd) {
WFIFOL(inter_fd, plen) = script_getvaridx(key.i64);
plen += 4;
- if( ((struct script_reg_state*)src)->type ) {
- struct script_reg_str *p = src;
+ if( src->type ) {
+ struct script_reg_str *p = (struct script_reg_str *)src;
WFIFOB(inter_fd, plen) = p->value ? 2 : 3;
plen += 1;
@@ -336,7 +336,7 @@ int intif_saveregistry(struct map_session_data *sd) {
}
} else {
- struct script_reg_num *p = src;
+ struct script_reg_num *p = (struct script_reg_num *)src;
WFIFOB(inter_fd, plen) = p->value ? 0 : 1;
plen += 1;
diff --git a/src/map/npc.h b/src/map/npc.h
index a3f07e79c..2f4401bf7 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -46,6 +46,7 @@ struct npc_shop_data {
struct npc_item_list *item;/* list */
unsigned short items;/* total */
};
+struct npc_parse;
struct npc_data {
struct block_list bl;
struct unit_data *ud;
@@ -67,7 +68,7 @@ struct npc_data {
unsigned short level;
unsigned short stat_point;
- void* chatdb; // pointer to a npc_parse struct (see npc_chat.c)
+ struct npc_parse *chatdb;
char* path;/* path dir */
enum npc_subtype subtype;
int src_id;
@@ -302,12 +303,6 @@ struct pcrematch_set {
/*
* Entire data structure hung off a NPC
- *
- * The reason I have done it this way (a void * in npc_data and then
- * this) was to reduce the number of patches that needed to be applied
- * to a ragnarok distribution to bring this code online. I
- * also wanted people to be able to grab this one file to get updates
- * without having to do a large number of changes.
*/
struct npc_parse {
struct pcrematch_set* active;
diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c
index 1372fff21..3f4a1a1c1 100644
--- a/src/map/npc_chat.c
+++ b/src/map/npc_chat.c
@@ -91,9 +91,9 @@ void finalize_pcrematch_entry(struct pcrematch_entry* e)
struct pcrematch_set* lookup_pcreset(struct npc_data* nd, int setid)
{
struct pcrematch_set *pcreset;
- struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
+ struct npc_parse *npcParse = nd->chatdb;
if (npcParse == NULL)
- nd->chatdb = npcParse = (struct npc_parse *) aCalloc(sizeof(struct npc_parse), 1);
+ nd->chatdb = npcParse = (struct npc_parse *)aCalloc(sizeof(struct npc_parse), 1);
pcreset = npcParse->active;
@@ -112,7 +112,7 @@ struct pcrematch_set* lookup_pcreset(struct npc_data* nd, int setid)
}
if (pcreset == NULL) {
- pcreset = (struct pcrematch_set *) aCalloc(sizeof(struct pcrematch_set), 1);
+ pcreset = (struct pcrematch_set *)aCalloc(sizeof(struct pcrematch_set), 1);
pcreset->next = npcParse->inactive;
if (pcreset->next != NULL)
pcreset->next->prev = pcreset;
@@ -132,7 +132,7 @@ struct pcrematch_set* lookup_pcreset(struct npc_data* nd, int setid)
void activate_pcreset(struct npc_data* nd, int setid)
{
struct pcrematch_set *pcreset;
- struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
+ struct npc_parse *npcParse = nd->chatdb;
if (npcParse == NULL)
return; // Nothing to activate...
pcreset = npcParse->inactive;
@@ -165,7 +165,7 @@ void activate_pcreset(struct npc_data* nd, int setid)
void deactivate_pcreset(struct npc_data* nd, int setid)
{
struct pcrematch_set *pcreset;
- struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
+ struct npc_parse *npcParse = nd->chatdb;
if (npcParse == NULL)
return; // Nothing to deactivate...
if (setid == -1) {
@@ -202,7 +202,7 @@ void delete_pcreset(struct npc_data* nd, int setid)
{
int active = 1;
struct pcrematch_set *pcreset;
- struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
+ struct npc_parse *npcParse = nd->chatdb;
if (npcParse == NULL)
return; // Nothing to deactivate...
pcreset = npcParse->active;
@@ -299,7 +299,7 @@ void npc_chat_def_pattern(struct npc_data* nd, int setid, const char* pattern, c
*/
void npc_chat_finalize(struct npc_data* nd)
{
- struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
+ struct npc_parse *npcParse = nd->chatdb;
if (npcParse == NULL)
return;
@@ -318,8 +318,8 @@ void npc_chat_finalize(struct npc_data* nd)
*/
int npc_chat_sub(struct block_list* bl, va_list ap)
{
- struct npc_data* nd = (struct npc_data *) bl;
- struct npc_parse* npcParse = (struct npc_parse *) nd->chatdb;
+ struct npc_data *nd = (struct npc_data *) bl;
+ struct npc_parse *npcParse = nd->chatdb;
char* msg;
int len, i;
struct map_session_data* sd;
diff --git a/src/map/script.c b/src/map/script.c
index 529ea7d5c..3bd6d033d 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -2594,7 +2594,7 @@ void* get_val2(struct script_state* st, int64 uid, struct DBMap** ref) {
script->push_val(st->stack, C_NAME, uid, ref);
data = script_getdatatop(st, -1);
script->get_val(st, data);
- return (data->type == C_INT ? (void*)__64BPTRSIZE(data->u.num) : (void*)__64BPTRSIZE(data->u.str));
+ return (data->type == C_INT ? (void*)__64BPTRSIZE((int32)data->u.num) : (void*)__64BPTRSIZE(data->u.str)); // u.num is int32 because it comes from script->get_val
}
/**
* Because, currently, array members with key 0 are indifferenciable from normal variables, we should ensure its actually in
@@ -2837,20 +2837,20 @@ int set_reg(struct script_state* st, TBL_PC* sd, int64 num, const char* name, co
i64db_put(n, num, aStrdup(str));
if( script_getvaridx(num) )
script->array_update(
- (name[1] == '@') ?
- &st->stack->array_function_db :
- &st->script->script_arrays_db,
- num,
- false);
+ (name[1] == '@') ?
+ &st->stack->array_function_db :
+ &st->script->script_arrays_db,
+ num,
+ false);
} else {
i64db_remove(n, num);
if( script_getvaridx(num) )
script->array_update(
- (name[1] == '@') ?
- &st->stack->array_function_db :
- &st->script->script_arrays_db,
- num,
- true);
+ (name[1] == '@') ?
+ &st->stack->array_function_db :
+ &st->script->script_arrays_db,
+ num,
+ true);
}
}
}
@@ -2908,20 +2908,20 @@ int set_reg(struct script_state* st, TBL_PC* sd, int64 num, const char* name, co
i64db_iput(n, num, val);
if( script_getvaridx(num) )
script->array_update(
- (name[1] == '@') ?
- &st->stack->array_function_db :
- &st->script->script_arrays_db,
- num,
- false);
+ (name[1] == '@') ?
+ &st->stack->array_function_db :
+ &st->script->script_arrays_db,
+ num,
+ false);
} else {
i64db_remove(n, num);
if( script_getvaridx(num) )
script->array_update(
- (name[1] == '@') ?
- &st->stack->array_function_db :
- &st->script->script_arrays_db,
- num,
- true);
+ (name[1] == '@') ?
+ &st->stack->array_function_db :
+ &st->script->script_arrays_db,
+ num,
+ true);
}
}
}
@@ -4113,15 +4113,15 @@ void script_setarray_pc(struct map_session_data* sd, const char* varname, uint32
* Clears persistent variables from memory
**/
int script_reg_destroy(DBKey key, DBData *data, va_list ap) {
- void *src;
+ struct script_reg_state *src;
if( data->type != DB_DATA_PTR )/* got no need for those! */
return 0;
src = DB->data2ptr(data);
- if( ((struct script_reg_state*)src)->type ) {
- struct script_reg_str *p = src;
+ if( src->type ) {
+ struct script_reg_str *p = (struct script_reg_str *)src;
if( p->value )
aFree(p->value);