summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-26 10:37:45 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-26 10:37:45 +0000
commit49e9510c432987393d10ec1b8b1c2d416c9feb42 (patch)
tree4d930ebf1094ad5972cb8ba20b89d12ce74d4f3c /src/map
parentfda87bd7ef5a71f4f5d5e604de1b15c58763efdd (diff)
downloadhercules-49e9510c432987393d10ec1b8b1c2d416c9feb42.tar.gz
hercules-49e9510c432987393d10ec1b8b1c2d416c9feb42.tar.bz2
hercules-49e9510c432987393d10ec1b8b1c2d416c9feb42.tar.xz
hercules-49e9510c432987393d10ec1b8b1c2d416c9feb42.zip
Adjusted eAthena code to compile cleanly in C++ mode.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12436 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c9
-rw-r--r--src/map/battle.c27
-rw-r--r--src/map/battle.h7
-rw-r--r--src/map/chrif.c7
-rw-r--r--src/map/clif.c104
-rw-r--r--src/map/clif.h12
-rw-r--r--src/map/guild.c28
-rw-r--r--src/map/intif.c8
-rw-r--r--src/map/itemdb.c10
-rw-r--r--src/map/log.c4
-rw-r--r--src/map/log.h4
-rw-r--r--src/map/map.c18
-rw-r--r--src/map/map.h5
-rw-r--r--src/map/mercenary.c2
-rw-r--r--src/map/mercenary.h11
-rw-r--r--src/map/mob.c16
-rw-r--r--src/map/npc.c16
-rw-r--r--src/map/party.c8
-rw-r--r--src/map/pc.c26
-rw-r--r--src/map/pc.h52
-rw-r--r--src/map/pet.h79
-rw-r--r--src/map/script.c102
-rw-r--r--src/map/script.h4
-rw-r--r--src/map/skill.c135
-rw-r--r--src/map/status.c74
-rw-r--r--src/map/status.h10
-rw-r--r--src/map/storage.c8
27 files changed, 415 insertions, 371 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 233376655..38de48e57 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -2394,7 +2394,7 @@ int atcommand_monster(const int fd, struct map_session_data* sd, const char* com
ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y);
count = 0;
- range = (int)sqrt(number) +2; // calculation of an odd number (+ 4 area around)
+ range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
for (i = 0; i < number; i++) {
map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "");
@@ -5365,7 +5365,7 @@ int atcommand_effect(const int fd, struct map_session_data* sd, const char* comm
return -1;
}
- clif_specialeffect(&sd->bl, type, flag);
+ clif_specialeffect(&sd->bl, type, (send_target)flag);
clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
return 0;
}
@@ -6997,9 +6997,8 @@ int atcommand_mobinfo(const int fd, struct map_session_data* sd, const char* com
*------------------------------------------*/
int atshowmobs_timer(int tid, unsigned int tick, int id, int data)
{
- struct map_session_data *sd;
-
- if (!session[id] || (sd = session[id]->session_data) == NULL)
+ struct map_session_data* sd = map_id2sd(id);
+ if( sd == NULL )
return 0;
clif_viewpoint(sd, 1, 2, 0, 0, data, 0xFFFFFF);
diff --git a/src/map/battle.c b/src/map/battle.c
index 6a60ea0a9..ae0c9d4a0 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -2754,11 +2754,11 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
int skillv;
struct Damage wd;
- nullpo_retr(0, src);
- nullpo_retr(0, target);
+ nullpo_retr(ATK_NONE, src);
+ nullpo_retr(ATK_NONE, target);
if (src->prev == NULL || target->prev == NULL)
- return 0;
+ return ATK_NONE;
sd = BL_CAST(BL_PC, src);
tsd = BL_CAST(BL_PC, target);
@@ -2782,7 +2782,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
damage = sd->equip_index[EQI_AMMO];
if (damage<0) {
clif_arrow_fail(sd,0);
- return 0;
+ return ATK_NONE;
}
//Ammo check by Ishizu-chan
if (sd->inventory_data[damage])
@@ -2790,7 +2790,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
case W_BOW:
if (sd->inventory_data[damage]->look != A_ARROW) {
clif_arrow_fail(sd,0);
- return 0;
+ return ATK_NONE;
}
break;
case W_REVOLVER:
@@ -2799,13 +2799,13 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
case W_SHOTGUN:
if (sd->inventory_data[damage]->look != A_BULLET) {
clif_arrow_fail(sd,0);
- return 0;
+ return ATK_NONE;
}
break;
case W_GRENADE:
if (sd->inventory_data[damage]->look != A_GRENADE) {
clif_arrow_fail(sd,0);
- return 0;
+ return ATK_NONE;
}
break;
}
@@ -2831,7 +2831,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
clif_damage(src, target, tick, sstatus->amotion, 1, 0, 1, 0, 0); //Display MISS.
status_change_end(target,SC_AUTOCOUNTER,-1);
skill_attack(BF_WEAPON,target,target,src,KN_AUTOCOUNTER,skilllv,tick,0);
- return 0;
+ return ATK_NONE;
}
}
if (tsc->data[SC_BLADESTOP_WAIT] && !is_boss(src)) {
@@ -2843,7 +2843,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
clif_damage(src, target, tick, sstatus->amotion, 1, 0, 1, 0, 0); //Display MISS.
clif_bladestop(target,src,1);
sc_start4(target, SC_BLADESTOP, 100, skilllv, 0, 0,(int)src, duration);
- return 0;
+ return ATK_NONE;
}
}
}
@@ -2857,15 +2857,18 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
status_change_end(src,SC_SKILLRATE_UP,-1);
}
if (rand()%100 < triple_rate)
- return skill_attack(BF_WEAPON,src,src,target,MO_TRIPLEATTACK,skillv,tick,0);
+ //FIXME: invalid return type!
+ return (damage_lv)skill_attack(BF_WEAPON,src,src,target,MO_TRIPLEATTACK,skillv,tick,0);
}
if (sc)
{
if (sc->data[SC_SACRIFICE])
- return skill_attack(BF_WEAPON,src,src,target,PA_SACRIFICE,sc->data[SC_SACRIFICE]->val1,tick,0);
+ //FIXME: invalid return type!
+ return (damage_lv)skill_attack(BF_WEAPON,src,src,target,PA_SACRIFICE,sc->data[SC_SACRIFICE]->val1,tick,0);
if (sc->data[SC_MAGICALATTACK])
- return skill_attack(BF_MAGIC,src,src,target,NPC_MAGICALATTACK,sc->data[SC_MAGICALATTACK]->val1,tick,0);
+ //FIXME: invalid return type!
+ return (damage_lv)skill_attack(BF_MAGIC,src,src,target,NPC_MAGICALATTACK,sc->data[SC_MAGICALATTACK]->val1,tick,0);
}
wd = battle_calc_weapon_attack(src, target, 0, 0, flag);
diff --git a/src/map/battle.h b/src/map/battle.h
index 287b4ed61..c6c2eb2e9 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -5,11 +5,12 @@
#define _BATTLE_H_
// state of a single attack attempt; used in flee/def penalty calculations when mobbed
-enum damage_lv {
- ATK_LUCKY=1, // attack was lucky-dodged
+typedef enum damage_lv {
+ ATK_NONE, // not an attack
+ ATK_LUCKY, // attack was lucky-dodged
ATK_FLEE, // attack was dodged
ATK_DEF // attack connected
-};
+} damage_lv;
// ダメージ
struct Damage {
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 7194819cf..7ef032f16 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -106,8 +106,9 @@ int other_mapserver_count=0; //Holds count of how many other map servers are onl
//This define should spare writing the check in every function. [Skotlex]
#define chrif_check(a) { if(!chrif_isconnected()) return a; }
-struct auth_node* chrif_search(int account_id) {
- return idb_get(auth_db, account_id);
+struct auth_node* chrif_search(int account_id)
+{
+ return (struct auth_node*)idb_get(auth_db, account_id);
}
struct auth_node* chrif_auth_check(int account_id, int char_id, enum sd_state state) {
@@ -1234,7 +1235,7 @@ int chrif_load_scdata(int fd)
for (i = 0; i < count; i++)
{
data = (struct status_change_data*)RFIFOP(fd,14 + i*sizeof(struct status_change_data));
- status_change_start(&sd->bl, data->type, 10000, data->val1, data->val2, data->val3, data->val4, data->tick, 15);
+ status_change_start(&sd->bl, (sc_type)data->type, 10000, data->val1, data->val2, data->val3, data->val4, data->tick, 15);
}
#endif
return 0;
diff --git a/src/map/clif.c b/src/map/clif.c
index a91c8d9ca..532d42ff1 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -678,7 +678,7 @@ static int clif_clearunit_delayed_sub(int tid, unsigned int tick, int id, int da
int clif_clearunit_delayed(struct block_list* bl, unsigned int tick)
{
struct block_list *tbl;
- tbl = aMalloc(sizeof (struct block_list));
+ tbl = (struct block_list*)aMalloc(sizeof (struct block_list));
memcpy (tbl, bl, sizeof (struct block_list));
add_timer(tick, clif_clearunit_delayed_sub, (int)tbl, 0);
return 0;
@@ -1009,21 +1009,18 @@ static void clif_weather_check(struct map_session_data *sd)
}
}
-int clif_weather(int m)
+void clif_weather(int m)
{
- int i;
-
+ struct s_mapiterator* iter;
struct map_session_data *sd=NULL;
- for(i = 0; i < fd_max; i++) {
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd = session[i]->session_data) != NULL &&
- sd->state.active && sd->bl.m == m) {
+ iter = mapit_getallusers();
+ for( sd = (struct map_session_data*)mapit_first(iter); mapit_exists(iter); sd = (struct map_session_data*)mapit_next(iter) )
+ {
+ if( sd->bl.m == m )
clif_weather_check(sd);
- }
}
-
- return 0;
+ mapit_free(iter);
}
int clif_spawn(struct block_list *bl)
@@ -2488,9 +2485,8 @@ void clif_changetraplook(struct block_list *bl,int val)
}
-//For the stupid cloth-dye bug. Resends the given view data
-//to the area specified by bl.
-void clif_refreshlook(struct block_list *bl,int id,int type,int val,int area)
+//For the stupid cloth-dye bug. Resends the given view data to the area specified by bl.
+void clif_refreshlook(struct block_list *bl,int id,int type,int val,enum send_target target)
{
unsigned char buf[32];
#if PACKETVER < 4
@@ -2498,14 +2494,14 @@ void clif_refreshlook(struct block_list *bl,int id,int type,int val,int area)
WBUFL(buf,2)=id;
WBUFB(buf,6)=type;
WBUFB(buf,7)=val;
- clif_send(buf,packet_len(0xc3),bl,area);
+ clif_send(buf,packet_len(0xc3),bl,target);
#else
WBUFW(buf,0)=0x1d7;
WBUFL(buf,2)=id;
WBUFB(buf,6)=type;
WBUFW(buf,7)=val;
WBUFW(buf,9)=0;
- clif_send(buf,packet_len(0x1d7),bl,area);
+ clif_send(buf,packet_len(0x1d7),bl,target);
#endif
return;
}
@@ -6485,9 +6481,9 @@ int clif_guild_expulsion(struct map_session_data *sd,const char *name,const char
nullpo_retr(0, sd);
WBUFW(buf, 0)=0x15c;
- safestrncpy(WBUFP(buf, 2),name,NAME_LENGTH);
- safestrncpy(WBUFP(buf,26),mes,40);
- safestrncpy(WBUFP(buf,66),"",NAME_LENGTH); // account name (not used for security reasons)
+ safestrncpy((char*)WBUFP(buf, 2),name,NAME_LENGTH);
+ safestrncpy((char*)WBUFP(buf,26),mes,40);
+ safestrncpy((char*)WBUFP(buf,66),"",NAME_LENGTH); // account name (not used for security reasons)
clif_send(buf,packet_len(0x15c),&sd->bl,GUILD);
return 0;
}
@@ -6512,9 +6508,9 @@ int clif_guild_expulsionlist(struct map_session_data *sd)
for(i=c=0;i<MAX_GUILDEXPULSION;i++){
struct guild_expulsion *e=&g->expulsion[i];
if(e->account_id>0){
- safestrncpy(WFIFOP(fd,4 + c*88),e->name,NAME_LENGTH);
- safestrncpy(WFIFOP(fd,4 + c*88+24),"",24); // account name (not used for security reasons)
- safestrncpy(WFIFOP(fd,4 + c*88+48),e->mes,40);
+ safestrncpy((char*)WFIFOP(fd,4 + c*88),e->name,NAME_LENGTH);
+ safestrncpy((char*)WFIFOP(fd,4 + c*88+24),"",24); // account name (not used for security reasons)
+ safestrncpy((char*)WFIFOP(fd,4 + c*88+48),e->mes,40);
c++;
}
}
@@ -8263,7 +8259,7 @@ void clif_parse_MapMove(int fd, struct map_session_data *sd)
/*==========================================
*
*------------------------------------------*/
-void clif_changed_dir(struct block_list *bl, int type)
+void clif_changed_dir(struct block_list *bl, enum send_target target)
{
unsigned char buf[64];
@@ -8272,7 +8268,8 @@ void clif_changed_dir(struct block_list *bl, int type)
WBUFW(buf,6) = bl->type==BL_PC?((TBL_PC*)bl)->head_dir:0;
WBUFB(buf,8) = unit_getdir(bl);
- clif_send(buf, packet_len(0x9c), bl, type);
+ clif_send(buf, packet_len(0x9c), bl, target);
+
if (disguised(bl)) {
WBUFL(buf,2) = -bl->id;
WBUFW(buf,6) = 0;
@@ -9005,10 +9002,13 @@ void clif_parse_TradeRequest(int fd,struct map_session_data *sd)
return;
}
- if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 1){
- trade_traderequest(sd,t_sd);
- } else
+ if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 1)
+ {
clif_skill_fail(sd,1,0,0);
+ return;
+ }
+
+ trade_traderequest(sd,t_sd);
}
/*==========================================
@@ -9712,19 +9712,24 @@ void clif_parse_StoragePassword(int fd, struct map_session_data *sd)
/*==========================================
- * パーティを作る
+ * Party creation request
+ * S 00f9 <party name>.24S
+ * S 01e8 <party name>.24S <item1>.B <item2>.B
*------------------------------------------*/
void clif_parse_CreateParty(int fd, struct map_session_data *sd)
{
if(map[sd->bl.m].flag.partylock)
- { //Guild locked.
+ {// Party locked.
clif_displaymessage(fd, msg_txt(227));
return;
}
- if (battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 7) {
- party_create(sd,(char*)RFIFOP(fd,2),0,0);
- } else
+ if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 7 )
+ {
clif_skill_fail(sd,1,0,4);
+ return;
+ }
+
+ party_create(sd,(char*)RFIFOP(fd,2),0,0);
}
/*==========================================
@@ -9733,33 +9738,38 @@ void clif_parse_CreateParty(int fd, struct map_session_data *sd)
void clif_parse_CreateParty2(int fd, struct map_session_data *sd)
{
if(map[sd->bl.m].flag.partylock)
- { //Guild locked.
+ {// Party locked.
clif_displaymessage(fd, msg_txt(227));
return;
}
- if (battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 7)
- party_create(sd,(char*)RFIFOP(fd,2),RFIFOB(fd,26),RFIFOB(fd,27));
- else
+ if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 7 )
+ {
clif_skill_fail(sd,1,0,4);
+ return;
+ }
+
+ party_create(sd,(char*)RFIFOP(fd,2),RFIFOB(fd,26),RFIFOB(fd,27));
}
/*==========================================
- * パーティに勧誘
+ * Party invitation request
+ * S 00fc <account ID>.L
+ * S 02c4 <char name>.24S
*------------------------------------------*/
void clif_parse_PartyInvite(int fd, struct map_session_data *sd)
{
struct map_session_data *t_sd;
if(map[sd->bl.m].flag.partylock)
- { //Guild locked.
+ {// Party locked.
clif_displaymessage(fd, msg_txt(227));
return;
}
t_sd = map_id2sd(RFIFOL(fd,2));
- // @noask [LuzZza]
- if(t_sd && t_sd->state.noask) {
+ if(t_sd && t_sd->state.noask)
+ {// @noask [LuzZza]
clif_noask_sub(sd, t_sd, 1);
return;
}
@@ -9771,18 +9781,18 @@ void clif_parse_PartyInvite2(int fd, struct map_session_data *sd)
{
struct map_session_data *t_sd;
char *name = (char*)RFIFOP(fd,2);
- name[NAME_LENGTH]='\0';
+ name[NAME_LENGTH-1] = '\0';
if(map[sd->bl.m].flag.partylock)
- { //Guild locked.
+ {// Party locked.
clif_displaymessage(fd, msg_txt(227));
return;
}
t_sd = map_nick2sd(name);
- // @noask [LuzZza]
- if(t_sd && t_sd->state.noask) {
+ if(t_sd && t_sd->state.noask)
+ {// @noask [LuzZza]
clif_noask_sub(sd, t_sd, 1);
return;
}
@@ -11710,7 +11720,7 @@ void clif_Auction_openwindow(struct map_session_data *sd)
WFIFOSET(fd,12);
}
-void clif_Auction_results(struct map_session_data *sd, short count, short pages, unsigned char *buf)
+void clif_Auction_results(struct map_session_data *sd, short count, short pages, uint8 *buf)
{
int i, fd = sd->fd, len = sizeof(struct auction_data);
struct auction_data auction;
@@ -11729,7 +11739,7 @@ void clif_Auction_results(struct map_session_data *sd, short count, short pages,
k = 12 + (i * 83);
WFIFOL(fd,k) = auction.auction_id;
- safestrncpy(WFIFOP(fd,4+k), auction.seller_name, NAME_LENGTH);
+ safestrncpy((char*)WFIFOP(fd,4+k), auction.seller_name, NAME_LENGTH);
if( (item = itemdb_search(auction.item.nameid)) != NULL && item->view_id > 0 )
WFIFOW(fd,28+k) = item->view_id;
@@ -11748,7 +11758,7 @@ void clif_Auction_results(struct map_session_data *sd, short count, short pages,
WFIFOW(fd,45+k) = auction.item.card[3];
WFIFOL(fd,47+k) = auction.price;
WFIFOL(fd,51+k) = auction.buynow;
- safestrncpy(WFIFOP(fd,55+k), auction.buyer_name, NAME_LENGTH);
+ safestrncpy((char*)WFIFOP(fd,55+k), auction.buyer_name, NAME_LENGTH);
WFIFOL(fd,79+k) = auction.timestamp;
}
WFIFOSET(fd, 12 + (count * 83));
diff --git a/src/map/clif.h b/src/map/clif.h
index 8c48b7277..d0a4fe4b4 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -56,7 +56,7 @@ struct s_packet_db {
extern struct s_packet_db packet_db[MAX_PACKET_VER+1][MAX_PACKET_DB+1];
// local define
-enum send_target {
+typedef enum send_target {
ALL_CLIENT,
ALL_SAMEMAP,
AREA, // area
@@ -82,7 +82,7 @@ enum send_target {
DUEL_WOS,
CHAT_MAINCHAT, // everyone on main chat
SELF,
-};
+} send_target;
int clif_setip(const char* ip);
void clif_setbindip(const char* ip);
@@ -132,7 +132,7 @@ void clif_sitting(struct block_list* bl);
void clif_standing(struct block_list* bl);
void clif_changelook(struct block_list *bl,int type,int val); // area
void clif_changetraplook(struct block_list *bl,int val); // area
-void clif_refreshlook(struct block_list *bl,int id,int type,int val,int area); //area specified in 'area'
+void clif_refreshlook(struct block_list *bl,int id,int type,int val,enum send_target target); //area specified in 'target'
int clif_arrowequip(struct map_session_data *sd,int val); //self
int clif_arrow_fail(struct map_session_data *sd,int type); //self
int clif_arrow_create_list(struct map_session_data *sd); //self
@@ -262,7 +262,7 @@ int clif_item_skill(struct map_session_data *sd,int skillid,int skilllv);
int clif_mvp_effect(struct map_session_data *sd);
int clif_mvp_item(struct map_session_data *sd,int nameid);
int clif_mvp_exp(struct map_session_data *sd, unsigned int exp);
-void clif_changed_dir(struct block_list *bl, int area);
+void clif_changed_dir(struct block_list *bl, enum send_target target);
// vending
void clif_openvendingreq(struct map_session_data* sd, int num);
@@ -355,7 +355,7 @@ void clif_friendslist_reqack(struct map_session_data *sd, struct map_session_dat
// [Valaris]
int clif_mob_hp(struct mob_data *md);
-int clif_weather(int m); // [Valaris]
+void clif_weather(int m); // [Valaris]
int clif_specialeffect(struct block_list* bl, int type, enum send_target target); // special effects [Valaris]
void clif_specialeffect_single(struct block_list* bl, int type, int fd);
int clif_message(struct block_list *bl, const char* msg); // messages (from mobs/npcs) [Valaris]
@@ -409,7 +409,7 @@ void clif_Mail_refreshinbox(struct map_session_data *sd);
void clif_Mail_getattachment(int fd, uint8 flag);
// AUCTION SYSTEM
void clif_Auction_openwindow(struct map_session_data *sd);
-void clif_Auction_results(struct map_session_data *sd, short count, short pages, unsigned char *buf);
+void clif_Auction_results(struct map_session_data *sd, short count, short pages, uint8 *buf);
void clif_Auction_message(int fd, unsigned char flag);
void clif_Auction_close(int fd, unsigned char flag);
void clif_parse_Auction_cancelreg(int fd, struct map_session_data *sd);
diff --git a/src/map/guild.c b/src/map/guild.c
index ed35aaccb..8413c5c37 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -223,7 +223,7 @@ static int guild_read_castledb(void)
/// lookup: guild id -> guild*
struct guild* guild_search(int guild_id)
{
- return idb_get(guild_db,guild_id);
+ return (struct guild*)idb_get(guild_db,guild_id);
}
/// lookup: guild name -> guild*
@@ -232,7 +232,7 @@ struct guild* guild_searchname(char* str)
struct guild* g;
DBIterator* iter = guild_db->iterator(guild_db);
- for( g = iter->first(iter,NULL); iter->exists(iter); g = iter->next(iter,NULL) )
+ for( g = (struct guild*)iter->first(iter,NULL); iter->exists(iter); g = (struct guild*)iter->next(iter,NULL) )
{
if( strcmpi(g->name, str) == 0 )
break;
@@ -245,7 +245,7 @@ struct guild* guild_searchname(char* str)
/// lookup: castle id -> castle*
struct guild_castle* guild_castle_search(int gcid)
{
- return idb_get(castle_db,gcid);
+ return (struct guild_castle*)idb_get(castle_db,gcid);
}
/// lookup: map index -> castle*
@@ -254,7 +254,7 @@ struct guild_castle* guild_mapindex2gc(short mapindex)
struct guild_castle* gc;
DBIterator* iter = castle_db->iterator(castle_db);
- for( gc = iter->first(iter,NULL); iter->exists(iter); gc = iter->next(iter,NULL) )
+ for( gc = (struct guild_castle*)iter->first(iter,NULL); iter->exists(iter); gc = (struct guild_castle*)iter->next(iter,NULL) )
{
if( gc->mapindex == mapindex )
break;
@@ -460,7 +460,7 @@ int guild_npc_request_info(int guild_id,const char *event)
ev=(struct eventlist *)aCalloc(sizeof(struct eventlist),1);
memcpy(ev->name,event,strlen(event));
//The one in the db becomes the next event from this.
- ev->next=idb_put(guild_infoevent_db,guild_id,ev);
+ ev->next = (struct eventlist*)idb_put(guild_infoevent_db,guild_id,ev);
}
return guild_request_info(guild_id);
@@ -521,7 +521,8 @@ int guild_recv_info(struct guild *sg)
nullpo_retr(0, sg);
- if((g=idb_get(guild_db,sg->guild_id))==NULL){
+ if((g = (struct guild*)idb_get(guild_db,sg->guild_id))==NULL)
+ {
guild_new = true;
g=(struct guild *)aCalloc(1,sizeof(struct guild));
idb_put(guild_db,sg->guild_id,g);
@@ -588,7 +589,8 @@ int guild_recv_info(struct guild *sg)
}
// イベントの発生
- if( (ev=idb_remove(guild_infoevent_db,sg->guild_id))!=NULL ){
+ if( (ev = (struct eventlist*)idb_remove(guild_infoevent_db,sg->guild_id))!=NULL )
+ {
while(ev){
npc_event_do(ev->name);
ev2=ev->next;
@@ -1141,7 +1143,7 @@ unsigned int guild_payexp(struct map_session_data *sd,unsigned int exp)
exp = (unsigned int) exp * per / 100;
//Otherwise tax everything.
- c = guild_expcache_db->ensure(guild_expcache_db, i2key(sd->status.char_id), create_expcache, sd);
+ c = (struct guild_expcache*)guild_expcache_db->ensure(guild_expcache_db, i2key(sd->status.char_id), create_expcache, sd);
if (c->exp > UINT_MAX - exp)
c->exp = UINT_MAX;
@@ -1161,7 +1163,7 @@ int guild_getexp(struct map_session_data *sd,int exp)
if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL)
return 0;
- c = guild_expcache_db->ensure(guild_expcache_db, i2key(sd->status.char_id), create_expcache, sd);
+ c = (struct guild_expcache*)guild_expcache_db->ensure(guild_expcache_db, i2key(sd->status.char_id), create_expcache, sd);
if (c->exp > UINT_MAX - exp)
c->exp = UINT_MAX;
else
@@ -1676,10 +1678,10 @@ int guild_addcastleinfoevent(int castle_id,int index,const char *name)
if( name==NULL || *name==0 )
return 0;
- ev=(struct eventlist *)aMalloc(sizeof(struct eventlist));
+ ev = (struct eventlist *)aMalloc(sizeof(struct eventlist));
memcpy(ev->name,name,sizeof(ev->name));
//The next event becomes whatever was currently stored.
- ev->next= idb_put(guild_castleinfoevent_db,code,ev);
+ ev->next = (struct eventlist *)idb_put(guild_castleinfoevent_db,code,ev);
return 0;
}
@@ -1720,7 +1722,9 @@ int guild_castledataloadack(int castle_id,int index,int value)
ShowError("guild_castledataloadack ERROR!! (Not found index=%d)\n", index);
return 0;
}
- if( (ev=idb_remove(guild_castleinfoevent_db,code))!=NULL ){
+
+ if( (ev = (struct eventlist *)idb_remove(guild_castleinfoevent_db,code))!=NULL )
+ {
while(ev){
npc_event_do(ev->name);
ev2=ev->next;
diff --git a/src/map/intif.c b/src/map/intif.c
index 51bbd740b..b0013aa52 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -585,7 +585,7 @@ int intif_guild_leave(int guild_id,int account_id,int char_id,int flag,const cha
WFIFOL(inter_fd, 6) = account_id;
WFIFOL(inter_fd,10) = char_id;
WFIFOB(inter_fd,14) = flag;
- safestrncpy(WFIFOP(inter_fd,15),mes,40);
+ safestrncpy((char*)WFIFOP(inter_fd,15),mes,40);
WFIFOSET(inter_fd,55);
return 0;
}
@@ -1702,12 +1702,14 @@ int intif_Auction_requestlist(int char_id, short type, int price, const char* se
static void intif_parse_Auction_results(int fd)
{
struct map_session_data *sd = map_charid2sd(RFIFOL(fd,4));
- short count = RFIFOW(fd,8), pages = RFIFOW(fd,10);
+ short count = RFIFOW(fd,8);
+ short pages = RFIFOW(fd,10);
+ uint8* data = RFIFOP(fd,12);
if( sd == NULL )
return;
- clif_Auction_results(sd, count, pages, (char *)RFIFOP(fd,12));
+ clif_Auction_results(sd, count, pages, data);
}
int intif_Auction_register(struct auction_data *auction)
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 7d2623fce..d8c767dc8 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -176,7 +176,7 @@ struct item_data* itemdb_exists(int nameid)
if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb_array) )
return itemdb_array[nameid];
- item = idb_get(itemdb_other,nameid);
+ item = (struct item_data*)idb_get(itemdb_other,nameid);
if( item == &dummy_item )
return NULL;// dummy data, doesn't exist
return item;
@@ -279,16 +279,16 @@ struct item_data* itemdb_load(int nameid)
if( id == NULL )
{
key.i = nameid;
- id = itemdb_array[nameid] = create_item_data(key, NULL);
+ id = itemdb_array[nameid] = (struct item_data*)create_item_data(key, NULL);
}
return id;
}
- id = idb_ensure(itemdb_other, nameid, create_item_data);
+ id = (struct item_data*)idb_ensure(itemdb_other, nameid, create_item_data);
if( id == &dummy_item )
{// Remove dummy_item, replace by real data.
key.i = nameid;
- id = create_item_data(key, NULL);
+ id = (struct item_data*)create_item_data(key, NULL);
idb_put(itemdb_other, nameid, id);
}
return id;
@@ -314,7 +314,7 @@ struct item_data* itemdb_search(int nameid)
key.i = nameid;
return (struct item_data*)return_dummy_data(key, NULL);
}
- return idb_ensure(itemdb_other,nameid,return_dummy_data);
+ return (struct item_data*)idb_ensure(itemdb_other,nameid,return_dummy_data);
}
/*==========================================
diff --git a/src/map/log.c b/src/map/log.c
index 0483b6387..5cafcf719 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -426,9 +426,9 @@ int log_config_read(char *cfgName)
if(sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2)
{
if(strcmpi(w1,"enable_logs") == 0) {
- log_config.enable_logs = (atoi(w2));
+ log_config.enable_logs = (log_what)atoi(w2);
if (log_config.enable_logs&1) //Log everything.
- log_config.enable_logs=0xFFFFFFFF;
+ log_config.enable_logs = LOG_ALL;
} else if(strcmpi(w1,"sql_logs") == 0) {
log_config.sql_logs = (bool)atoi(w2);
//start of common filter settings
diff --git a/src/map/log.h b/src/map/log.h
index 758bebd71..9745ce1f0 100644
--- a/src/map/log.h
+++ b/src/map/log.h
@@ -24,7 +24,7 @@ int log_mvpdrop(struct map_session_data *sd, int monster_id, int *log_mvp);
int log_config_read(char *cfgName);
-enum log_what {
+typedef enum log_what {
LOG_ALL = 0xFFF,
LOG_TRADES = 0x002,
LOG_VENDING = 0x004,
@@ -36,7 +36,7 @@ enum log_what {
LOG_USED_ITEMS = 0x100, // used by player
LOG_MVP_PRIZE = 0x200,
LOG_COMMAND_ITEMS = 0x400 // created/deleted through @/# commands
-};
+} log_what;
extern struct Log_Config {
enum log_what enable_logs;
diff --git a/src/map/map.c b/src/map/map.c
index 83f6b855e..33a5343c4 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -951,7 +951,7 @@ int map_foreachinpath(int (*func)(struct block_list*,va_list),int m,int x0,int y
if (length)
{ //Adjust final position to fit in the given area.
//TODO: Find an alternate method which does not requires a square root calculation.
- k = (int)sqrt(magnitude2);
+ k = (int)sqrt((float)magnitude2);
mx1 = x0 + (x1 - x0)*length/k;
my1 = y0 + (y1 - y0)*length/k;
len_limit = MAGNITUDE2(x0,y0, mx1,my1);
@@ -1449,7 +1449,7 @@ void map_addnickdb(int charid, const char* nick)
if( map_charid2sd(charid) )
return;// already online
- p = idb_ensure(nick_db, charid, create_charid2nick);
+ p = (struct charid2nick*)idb_ensure(nick_db, charid, create_charid2nick);
safestrncpy(p->nick, nick, sizeof(p->nick));
while( p->requests )
@@ -1471,7 +1471,7 @@ void map_delnickdb(int charid, const char* name)
struct charid_request* req;
struct map_session_data* sd;
- p = idb_remove(nick_db, charid);
+ p = (struct charid2nick*)idb_remove(nick_db, charid);
if( p == NULL )
return;
@@ -1734,7 +1734,7 @@ struct block_list * map_id2bl(int id)
if(id >= 0 && id < ARRAYLENGTH(objects))
bl = objects[id];
else
- bl = idb_get(id_db,id);
+ bl = (struct block_list*)idb_get(id_db,id);
return bl;
}
@@ -2149,7 +2149,7 @@ int map_random_dir(struct block_list *bl, short *x, short *y)
short yi = *y-bl->y;
short i=0, j;
int dist2 = xi*xi + yi*yi;
- short dist = (short)sqrt(dist2);
+ short dist = (short)sqrt((float)dist2);
short segment;
if (dist < 1) dist =1;
@@ -2158,7 +2158,7 @@ int map_random_dir(struct block_list *bl, short *x, short *y)
j = rand()%8; //Pick a random direction
segment = 1+(rand()%dist); //Pick a random interval from the whole vector in that direction
xi = bl->x + segment*dirx[j];
- segment = (short)sqrt(dist2 - segment*segment); //The complement of the previously picked segment
+ segment = (short)sqrt((float)(dist2 - segment*segment)); //The complement of the previously picked segment
yi = bl->y + segment*diry[j];
} while (
(map_getcell(bl->m,xi,yi,CELL_CHKNOPASS) || !path_search(NULL,bl->m,bl->x,bl->y,xi,yi,1,CELL_CHKNOREACH))
@@ -2385,7 +2385,7 @@ int map_eraseipport(unsigned short mapindex, uint32 ip, uint16 port)
{
struct map_data_other_server *mdos;
- mdos = uidb_get(map_db,(unsigned int)mapindex);
+ mdos = (struct map_data_other_server*)uidb_get(map_db,(unsigned int)mapindex);
if(!mdos || mdos->cell) //Map either does not exists or is a local map.
return 0;
@@ -2432,8 +2432,8 @@ int map_readfromcache(struct map_data *m, FILE *fp)
m->ys = info.ys;
size = info.xs*info.ys;
- buf = aMalloc(info.len); // temp buffer to read the zipped map
- buf2 = aMalloc(size); // temp buffer to unpack the data
+ buf = (unsigned char*)aMalloc(info.len); // temp buffer to read the zipped map
+ buf2 = (unsigned char*)aMalloc(size); // temp buffer to unpack the data
CREATE(m->cell, struct mapcell, size);
fread(buf, info.len, 1, fp);
diff --git a/src/map/map.h b/src/map/map.h
index bf168b20c..1dbc4581a 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -176,11 +176,12 @@ enum bl_type {
BL_SKILL = 0x020,
BL_NPC = 0x040,
BL_CHAT = 0x080,
+
+ BL_ALL = 0xFFF,
};
//For common mapforeach calls. Since pets cannot be affected, they aren't included here yet.
#define BL_CHAR (BL_PC|BL_MOB|BL_HOM)
-#define BL_ALL 0xfff
enum npc_subtype { WARP, SHOP, SCRIPT, CASHSHOP };
@@ -228,6 +229,7 @@ struct block_list {
enum bl_type type;
};
+
// Mob List Held in memory for Dynamic Mobs [Wizputer]
// Expanded to specify all mob-related spawn data by [Skotlex]
struct spawn_data {
@@ -248,6 +250,7 @@ struct spawn_data {
+
struct flooritem_data {
struct block_list bl;
unsigned char subx,suby;
diff --git a/src/map/mercenary.c b/src/map/mercenary.c
index 039a7f446..66658a1d9 100644
--- a/src/map/mercenary.c
+++ b/src/map/mercenary.c
@@ -606,7 +606,7 @@ int merc_hom_alloc(struct map_session_data *sd, struct s_homunculus *hom)
intif_homunculus_requestdelete(hom->hom_id);
return 1;
}
- sd->hd = hd = aCalloc(1,sizeof(struct homun_data));
+ sd->hd = hd = (struct homun_data*)aCalloc(1,sizeof(struct homun_data));
hd->bl.type = BL_HOM;
hd->bl.id = npc_get_new_npc_id();
diff --git a/src/map/mercenary.h b/src/map/mercenary.h
index 2e90786cd..88692b4d1 100644
--- a/src/map/mercenary.h
+++ b/src/map/mercenary.h
@@ -7,18 +7,21 @@
#include "status.h" // struct status_data, struct status_change
#include "unit.h" // struct unit_data
+struct h_stats {
+ unsigned int HP, SP;
+ unsigned short str, agi, vit, int_, dex, luk;
+};
+
struct s_homunculus_db {
int base_class, evo_class;
char name[NAME_LENGTH];
- struct h_stats {
- unsigned int HP, SP;
- unsigned short str, agi, vit, int_, dex, luk;
- } base, gmin, gmax, emin, emax;
+ struct h_stats base, gmin, gmax, emin, emax;
int foodID ;
int baseASPD ;
long hungryDelay ;
unsigned char element, race, base_size, evo_size;
};
+
extern struct s_homunculus_db homuncumlus_db[MAX_HOMUNCULUS_CLASS];
enum { HOMUNCULUS_CLASS, HOMUNCULUS_FOOD };
enum {
diff --git a/src/map/mob.c b/src/map/mob.c
index bd9ed5d43..6463c2103 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -209,7 +209,7 @@ int mob_parse_dataset(struct spawn_data *data)
*------------------------------------------*/
struct mob_data* mob_spawn_dataset(struct spawn_data *data)
{
- struct mob_data *md = aCalloc(1, sizeof(struct mob_data));
+ struct mob_data *md = (struct mob_data*)aCalloc(1, sizeof(struct mob_data));
md->bl.id= npc_get_new_npc_id();
md->bl.type = BL_MOB;
md->bl.m = data->m;
@@ -419,7 +419,7 @@ int mob_once_spawn(struct map_session_data* sd, int m, short x, short y, const c
struct guild_castle* gc = guild_mapindex2gc(map[m].index);
struct guild* g = gc?guild_search(gc->guild_id):NULL;
if(gc) {
- md->guardian_data = aCalloc(1, sizeof(struct guardian_data));
+ md->guardian_data = (struct guardian_data*)aCalloc(1, sizeof(struct guardian_data));
md->guardian_data->castle = gc;
md->guardian_data->number = MAX_GUARDIANS;
md->guardian_data->guild_id = gc->guild_id;
@@ -586,7 +586,7 @@ void mob_barricade_get(struct map_session_data *sd)
return;
iter = barricade_db->iterator(barricade_db);
- for( barricade = iter->first(iter,&key); iter->exists(iter); barricade = iter->next(iter,&key) )
+ for( barricade = (struct barricade_data *)iter->first(iter,&key); iter->exists(iter); barricade = (struct barricade_data *)iter->next(iter,&key) )
{
if( sd->bl.m != barricade->m )
continue;
@@ -655,7 +655,7 @@ void mod_barricade_clearall(void)
int i;
iter = barricade_db->iterator(barricade_db);
- for( barricade = iter->first(iter,&key); iter->exists(iter); barricade = iter->next(iter,&key) )
+ for( barricade = (struct barricade_data *)iter->first(iter,&key); iter->exists(iter); barricade = (struct barricade_data *)iter->next(iter,&key) )
{
for( i = 0; i < barricade->count; i++ )
{
@@ -789,8 +789,8 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam
}
}
- md= mob_spawn_dataset(&data);
- md->guardian_data = aCalloc(1, sizeof(struct guardian_data));
+ md = mob_spawn_dataset(&data);
+ md->guardian_data = (struct guardian_data*)aCalloc(1, sizeof(struct guardian_data));
md->guardian_data->number = guardian;
md->guardian_data->guild_id = gc->guild_id;
md->guardian_data->castle = gc;
@@ -3539,7 +3539,7 @@ static bool mob_parse_dbrow(char** str)
}
if (mob_db_data[class_] == NULL)
- mob_db_data[class_] = aCalloc(1, sizeof (struct mob_db));
+ mob_db_data[class_] = (struct mob_db*)aCalloc(1, sizeof (struct mob_db));
db = mob_db_data[class_];
status = &db->status;
@@ -4379,7 +4379,7 @@ void mob_clear_spawninfo()
int do_init_mob(void)
{ //Initialize the mob database
memset(mob_db_data,0,sizeof(mob_db_data)); //Clear the array
- mob_db_data[0] = aCalloc(1, sizeof (struct mob_db)); //This mob is used for random spawns
+ mob_db_data[0] = (struct mob_db*)aCalloc(1, sizeof (struct mob_db)); //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(sizeof(struct item_drop));
item_drop_list_ers = ers_new(sizeof(struct item_drop_list));
diff --git a/src/map/npc.c b/src/map/npc.c
index 09f101983..51c95cee0 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -113,7 +113,7 @@ int npc_enable_sub(struct block_list *bl, va_list ap)
int npc_enable(const char* name, int flag)
{
- struct npc_data* nd = strdb_get(npcname_db, name);
+ struct npc_data* nd = (struct npc_data*)strdb_get(npcname_db, name);
if (nd==NULL)
return 0;
@@ -559,7 +559,7 @@ void npc_timerevent_quit(struct map_session_data* sd)
char buf[NAME_LENGTH*2+3];
struct event_data *ev;
snprintf(buf, ARRAYLENGTH(buf), "%s::OnTimerQuit", nd->exname);
- ev = strdb_get(ev_db, buf);
+ ev = (struct event_data*)strdb_get(ev_db, buf);
if(ev && ev->nd != nd) {
ShowWarning("npc_timerevent_quit: Unable to execute \"OnTimerQuit\", two NPCs have the same event name [%s]!\n",buf);
ev = NULL;
@@ -659,7 +659,7 @@ int npc_event_sub(struct map_session_data* sd, struct event_data* ev, const char
*------------------------------------------*/
int npc_event(struct map_session_data* sd, const char* eventname, int mob_kill)
{
- struct event_data* ev = strdb_get(ev_db, eventname);
+ struct event_data* ev = (struct event_data*)strdb_get(ev_db, eventname);
struct npc_data *nd;
int xs,ys;
char mobevent[100];
@@ -676,7 +676,7 @@ int npc_event(struct map_session_data* sd, const char* eventname, int mob_kill)
if (mob_kill) {
strcpy( mobevent, eventname);
strcat( mobevent, "::OnMyMobDead");
- ev = strdb_get(ev_db, mobevent);
+ ev = (struct event_data*)strdb_get(ev_db, mobevent);
if (ev == NULL || (nd = ev->nd) == NULL) {
ShowError("npc_event: (mob_kill) event not found [%s]\n", mobevent);
return 0;
@@ -2331,7 +2331,7 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c
//Now that all has been validated. We allocate the actual memory
//that the re-spawn data will use.
- data = aMalloc(sizeof(struct spawn_data));
+ data = (struct spawn_data*)aMalloc(sizeof(struct spawn_data));
memcpy(data, &mob, sizeof(struct spawn_data));
if( !battle_config.dynamic_mobs ) {
@@ -2632,7 +2632,7 @@ void npc_parsesrcfile(const char* filepath)
lines++;
// w1<TAB>w2<TAB>w3<TAB>w4
- count = sv_parse(p, len+buffer-p, 0, '\t', pos, ARRAYLENGTH(pos), SV_TERMINATE_LF|SV_TERMINATE_CRLF);
+ count = sv_parse(p, len+buffer-p, 0, '\t', pos, ARRAYLENGTH(pos), (e_svopt)(SV_TERMINATE_LF|SV_TERMINATE_CRLF));
if( count < 0 )
{
ShowError("npc_parsesrcfile: Parse error in file '%s', line '%d'. Stopping...\n", filepath, strline(buffer,p-buffer));
@@ -2810,7 +2810,7 @@ int npc_reload(void)
//Remove all npcs/mobs. [Skotlex]
iter = mapit_geteachiddb();
- for( bl = mapit_first(iter); mapit_exists(iter); bl = mapit_next(iter) )
+ for( bl = (struct block_list*)mapit_first(iter); mapit_exists(iter); bl = (struct block_list*)mapit_next(iter) )
{
switch(bl->type) {
case BL_NPC:
@@ -2954,7 +2954,7 @@ int do_init_npc(void)
for( i = 1; i < MAX_NPC_CLASS; i++ )
npc_viewdb[i].class_ = i;
- ev_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA,2*NAME_LENGTH+2+1);
+ ev_db = strdb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA),2*NAME_LENGTH+2+1);
npcname_db = strdb_alloc(DB_OPT_BASE,NAME_LENGTH);
timer_event_ers = ers_new(sizeof(struct timer_event_data));
diff --git a/src/map/party.c b/src/map/party.c
index 8e97d1f05..2d81e155c 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -86,7 +86,7 @@ struct party_data* party_search(int party_id)
{
if(!party_id)
return NULL;
- return idb_get(party_db,party_id);
+ return (struct party_data*)idb_get(party_db,party_id);
}
/// Party data lookup using party name.
@@ -95,7 +95,7 @@ struct party_data* party_searchname(const char* str)
struct party_data* p;
DBIterator* iter = party_db->iterator(party_db);
- for( p = iter->first(iter,NULL); iter->exists(iter); p = iter->next(iter,NULL) )
+ for( p = (struct party_data*)iter->first(iter,NULL); iter->exists(iter); p = (struct party_data*)iter->next(iter,NULL) )
{
if( strncmpi(p->party.name,str,NAME_LENGTH) == 0 )
break;
@@ -235,7 +235,7 @@ int party_recv_info(struct party *sp)
nullpo_retr(0, sp);
- p= idb_ensure(party_db, sp->party_id, create_party);
+ p = (struct party_data*)idb_ensure(party_db, sp->party_id, create_party);
if (!p->party.party_id) //party just received.
{
party_new = true;
@@ -726,7 +726,7 @@ int party_send_xy_timer(int tid,unsigned int tick,int id,int data)
DBIterator* iter = party_db->iterator(party_db);
// for each existing party,
- for( p = iter->first(iter,NULL); iter->exists(iter); p = iter->next(iter,NULL) )
+ for( p = (struct party_data*)iter->first(iter,NULL); iter->exists(iter); p = (struct party_data*)iter->next(iter,NULL) )
{
int i;
// for each member of this party,
diff --git a/src/map/pc.c b/src/map/pc.c
index 86d9f186d..838de158d 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -1339,7 +1339,7 @@ void pc_autoscript_clear(struct s_autoscript *scripts, int max)
memset(scripts, 0, i*sizeof(struct s_autoscript));
}
-static int pc_bonus_autospell_del(struct s_autospell *spell, int max, short id, short lv, short rate, short card_id)
+static int pc_bonus_autospell_del(struct s_autospell* spell, int max, short id, short lv, short rate, short card_id)
{
int i, j;
for(i=max-1; i>=0 && !spell[i].id; i--);
@@ -1405,7 +1405,7 @@ static int pc_bonus_autospell(struct s_autospell *spell, int max, short id, shor
return 1;
}
-static int pc_bonus_addeff(struct s_addeffect* effect, int max, short id, short rate, short arrow_rate, unsigned char flag)
+static int pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type id, short rate, short arrow_rate, unsigned char flag)
{
int i;
if (!(flag&(ATF_SHORT|ATF_LONG)))
@@ -2081,7 +2081,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
ShowWarning("pc_bonus2 (Add Effect): %d is not supported.\n", type2);
break;
}
- pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), type2,
+ pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
sd->state.lr_flag!=2?val:0, sd->state.lr_flag==2?val:0, 0);
break;
case SP_ADDEFF2:
@@ -2089,7 +2089,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
ShowWarning("pc_bonus2 (Add Effect2): %d is not supported.\n", type2);
break;
}
- pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), type2,
+ pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
sd->state.lr_flag!=2?val:0, sd->state.lr_flag==2?val:0, ATF_SELF);
break;
case SP_RESEFF:
@@ -2304,7 +2304,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
break;
}
if(sd->state.lr_flag != 2)
- pc_bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), type2, val, 0, 0);
+ pc_bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), (sc_type)type2, val, 0, 0);
break;
case SP_SKILL_ATK:
if(sd->state.lr_flag == 2)
@@ -2548,7 +2548,7 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
ShowWarning("pc_bonus3 (Add Effect): %d is not supported.\n", type2);
break;
}
- pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), type2,
+ pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
sd->state.lr_flag!=2?type3:0, sd->state.lr_flag==2?type3:0, val);
break;
@@ -2558,7 +2558,7 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
break;
}
if(sd->state.lr_flag != 2)
- pc_bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), type2, type3, 0, val);
+ pc_bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), (sc_type)type2, type3, 0, val);
break;
default:
@@ -3757,7 +3757,7 @@ int pc_checkskill(struct map_session_data *sd,int skill_id)
*------------------------------------------*/
int pc_checkallowskill(struct map_session_data *sd)
{
- const int scw_list[] = {
+ const enum sc_type scw_list[] = {
SC_TWOHANDQUICKEN,
SC_ONEHAND,
SC_AURABLADE,
@@ -3767,7 +3767,7 @@ int pc_checkallowskill(struct map_session_data *sd)
SC_ADRENALINE2,
SC_GATLINGFEVER
};
- const int scs_list[] = {
+ const enum sc_type scs_list[] = {
SC_AUTOGUARD,
SC_DEFENDER,
SC_REFLECTSHIELD
@@ -5624,12 +5624,12 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
if ((b_class&&MAPID_UPPERMASK) != (sd->class_&MAPID_UPPERMASK))
{ //Things to remove when changing class tree.
const int class_ = pc_class2idx(sd->status.class_);
- int id;
+ short id;
for(i = 0; i < MAX_SKILL_TREE && (id = skill_tree[class_][i].id) > 0; i++) {
//Remove status specific to your current tree skills.
- id = status_skill2sc(id);
- if (id > SC_COMMON_MAX && sd->sc.data[id])
- status_change_end(&sd->bl, id, -1);
+ enum sc_type sc = status_skill2sc(id);
+ if (sc > SC_COMMON_MAX && sd->sc.data[sc])
+ status_change_end(&sd->bl, sc, -1);
}
}
diff --git a/src/map/pc.h b/src/map/pc.h
index a7d30d1ce..245ecd686 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -45,6 +45,26 @@ struct weapon_data {
} add_dmg[MAX_PC_BONUS];
};
+struct s_autospell {
+ short id, lv, rate, card_id, flag;
+};
+
+struct s_addeffect {
+ enum sc_type id;
+ short rate, arrow_rate;
+ unsigned char flag;
+};
+
+struct s_add_drop {
+ short id, group;
+ int race, rate;
+};
+
+struct s_autoscript {
+ unsigned short rate, flag;
+ struct script_code *script;
+};
+
struct map_session_data {
struct block_list bl;
struct unit_data ud;
@@ -185,13 +205,8 @@ struct map_session_data {
short sp_gain_race[RC_MAX];
// zeroed arrays end here.
// zeroed structures start here
- struct s_autospell{
- short id, lv, rate, card_id, flag;
- } autospell[15], autospell2[15];
- struct s_addeffect{
- short id, rate, arrow_rate;
- unsigned char flag;
- } addeff[MAX_PC_BONUS], addeff2[MAX_PC_BONUS];
+ struct s_autospell autospell[15], autospell2[15];
+ struct s_addeffect addeff[MAX_PC_BONUS], addeff2[MAX_PC_BONUS];
struct { //skillatk raises bonus dmg% of skills, skillheal increases heal%, skillblown increases bonus blewcount for some skills.
unsigned short id;
short val;
@@ -203,22 +218,15 @@ struct map_session_data {
} hp_loss, sp_loss, hp_regen, sp_regen;
struct {
short class_, rate;
- } add_def[MAX_PC_BONUS], add_mdef[MAX_PC_BONUS],
- add_mdmg[MAX_PC_BONUS];
- struct s_add_drop {
- short id, group;
- int race, rate;
- } add_drop[MAX_PC_BONUS];
+ } add_def[MAX_PC_BONUS], add_mdef[MAX_PC_BONUS], add_mdmg[MAX_PC_BONUS];
+ struct s_add_drop add_drop[MAX_PC_BONUS];
struct {
int nameid;
int rate;
} itemhealrate[MAX_PC_BONUS];
// zeroed structures end here
// manually zeroed structures start here.
- struct s_autoscript {
- unsigned short rate, flag;
- struct script_code *script;
- } autoscript[10], autoscript2[10]; //Auto script on attack, when attacked
+ struct s_autoscript autoscript[10], autoscript2[10]; //Auto script on attack, when attacked
// manually zeroed structures end here.
// zeroed vars start here.
int arrow_atk,arrow_ele,arrow_cri,arrow_hit;
@@ -382,15 +390,15 @@ enum weapon_type {
W_DOUBLE_SA, // sword + axe
};
-enum {
+enum ammo_type {
A_ARROW = 1,
- A_DAGGER, //2
+ A_DAGGER, //2
A_BULLET, //3
A_SHELL, //4
A_GRENADE, //5
A_SHURIKEN, //6
A_KUNAI //7
-} ammo_type;
+};
//Equip position constants
enum equip_pos {
@@ -415,7 +423,7 @@ enum equip_pos {
//Equip indexes constants. (eg: sd->equip_index[EQI_AMMO] returns the index
//where the arrows are equipped)
-enum {
+enum equip_index {
EQI_ACC_L = 0,
EQI_ACC_R,
EQI_SHOES,
@@ -428,7 +436,7 @@ enum {
EQI_HAND_R,
EQI_AMMO,
EQI_MAX
-} equip_index_enum;
+};
struct duel {
int members_count;
diff --git a/src/map/pet.h b/src/map/pet.h
index eeb48f018..86b9080eb 100644
--- a/src/map/pet.h
+++ b/src/map/pet.h
@@ -33,6 +33,43 @@ extern struct s_pet_db pet_db[MAX_PET_DB];
enum { PET_CLASS,PET_CATCH,PET_EGG,PET_EQUIP,PET_FOOD };
+struct pet_recovery { //Stat recovery
+ enum sc_type type; //Status Change id
+ unsigned short delay; //How long before curing (secs).
+ int timer;
+};
+
+struct pet_bonus {
+ unsigned short type; //bStr, bVit?
+ unsigned short val; //Qty
+ unsigned short duration; //in secs
+ unsigned short delay; //Time before recasting (secs)
+ int timer;
+};
+
+struct pet_skill_attack { //Attack Skill
+ unsigned short id;
+ unsigned short lv;
+ unsigned short div_; //0 = Normal skill. >0 = Fixed damage (lv), fixed div_.
+ unsigned short rate; //Base chance of skill ocurrance (10 = 10% of attacks)
+ unsigned short bonusrate; //How being 100% loyal affects cast rate (10 = At 1000 intimacy->rate+10%
+};
+
+struct pet_skill_support { //Support Skill
+ unsigned short id;
+ unsigned short lv;
+ unsigned short hp; //Max HP% for skill to trigger (50 -> 50% for Magnificat)
+ unsigned short sp; //Max SP% for skill to trigger (100 = no check)
+ unsigned short delay; //Time (secs) between being able to recast.
+ int timer;
+};
+
+struct pet_loot {
+ struct item *item;
+ unsigned short count;
+ unsigned short weight;
+ unsigned short max;
+};
struct pet_data {
struct block_list bl;
@@ -51,43 +88,11 @@ struct pet_data {
unsigned int next_walktime,last_thinktime;
short rate_fix; //Support rate as modified by intimacy (1000 = 100%) [Skotlex]
- struct pet_recovery { //Stat recovery
- unsigned short type; //Status Change id
- unsigned short delay; //How long before curing (secs).
- int timer;
- } *recovery; //[Valaris] / Reimplemented by [Skotlex]
-
- struct pet_bonus {
- unsigned short type; //bStr, bVit?
- unsigned short val; //Qty
- unsigned short duration; //in secs
- unsigned short delay; //Time before recasting (secs)
- int timer;
- } *bonus; //[Valaris] / Reimplemented by [Skotlex]
-
- struct pet_skill_attack { //Attack Skill
- unsigned short id;
- unsigned short lv;
- unsigned short div_; //0 = Normal skill. >0 = Fixed damage (lv), fixed div_.
- unsigned short rate; //Base chance of skill ocurrance (10 = 10% of attacks)
- unsigned short bonusrate; //How being 100% loyal affects cast rate (10 = At 1000 intimacy->rate+10%
- } *a_skill; //[Skotlex]
-
- struct pet_skill_support { //Support Skill
- unsigned short id;
- unsigned short lv;
- unsigned short hp; //Max HP% for skill to trigger (50 -> 50% for Magnificat)
- unsigned short sp; //Max SP% for skill to trigger (100 = no check)
- unsigned short delay; //Time (secs) between being able to recast.
- int timer;
- } *s_skill; //[Skotlex]
-
- struct pet_loot {
- struct item *item;
- unsigned short count;
- unsigned short weight;
- unsigned short max;
- } *loot; //[Valaris] / Rewritten by [Skotlex]
+ struct pet_recovery* recovery;
+ struct pet_bonus* bonus;
+ struct pet_skill_attack* a_skill;
+ struct pet_skill_support* s_skill;
+ struct pet_loot* loot;
struct map_session_data *msd;
};
diff --git a/src/map/script.c b/src/map/script.c
index 9aa292e63..339afb495 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -30,6 +30,7 @@
#include "mercenary.h" //[orn]
#include "intif.h"
#include "skill.h"
+#include "status.h"
#include "chat.h"
#include "battle.h"
#include "party.h"
@@ -251,14 +252,16 @@ char mapregsql_db_index[32] = "index";
char mapregsql_db_value[32] = "value";
#endif
-int get_com(unsigned char *script,int *pos);
+c_op get_com(unsigned char *script,int *pos);
int get_num(unsigned char *script,int *pos);
-struct script_function {
+typedef struct script_function {
int (*func)(struct script_state *st);
const char *name;
const char *arg;
-} buildin_func[];
+} script_function;
+
+extern script_function buildin_func[];
static struct linkdb_node *sleep_db;
#define not_server_variable(prefix) ( (prefix) != '$' && (prefix) != '.')
@@ -1851,7 +1854,7 @@ void script_error(const char *src,const char *file,int start_line, const char *e
const char *linestart[5] = { NULL, NULL, NULL, NULL, NULL };
for(p=src;p && *p;line++){
- char *lineend=strchr(p,'\n');
+ const char *lineend=strchr(p,'\n');
if(lineend==NULL || error_pos<lineend){
break;
}
@@ -2167,7 +2170,7 @@ void get_val(struct script_state* st, struct script_data* data)
data->ref ? data->ref:
name[1] == '@' ? st->stack->var_function:// instance/scope variable
&st->script->script_vars;// npc variable
- data->u.str = linkdb_search(n, (void*)reference_getuid(data));
+ data->u.str = (char*)linkdb_search(n, (void*)reference_getuid(data));
}
break;
default:
@@ -2234,7 +2237,7 @@ void get_val(struct script_state* st, struct script_data* data)
return;
}
-void push_val2(struct script_stack* stack, int type, int val, struct linkdb_node** ref);
+void push_val2(struct script_stack* stack, enum c_op type, int val, struct linkdb_node** ref);
/// Retrieves the value of a reference identified by uid (variable, constant, param)
/// The value is left in the top of the stack and needs to be removed manually.
@@ -2271,7 +2274,7 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, char* name, con
char* p;
struct linkdb_node** n;
n = (ref) ? ref : (name[1] == '@') ? st->stack->var_function : &st->script->script_vars;
- p = linkdb_erase(n, (void*)num);
+ p = (char*)linkdb_erase(n, (void*)num);
if (p) aFree(p);
if (str[0]) linkdb_insert(n, (void*)num, aStrdup(str));
}
@@ -2423,7 +2426,7 @@ void stack_expand(struct script_stack* stack)
#define push_val(stack,type,val) push_val2(stack, type, val, NULL)
/// Pushes a value into the stack (with reference)
-void push_val2(struct script_stack* stack, int type, int val, struct linkdb_node** ref)
+void push_val2(struct script_stack* stack, enum c_op type, int val, struct linkdb_node** ref)
{
if( stack->sp >= stack->sp_max )
stack_expand(stack);
@@ -2434,7 +2437,7 @@ void push_val2(struct script_stack* stack, int type, int val, struct linkdb_node
}
/// Pushes a string into the stack
-void push_str(struct script_stack* stack, int type, char* str)
+void push_str(struct script_stack* stack, enum c_op type, char* str)
{
if( stack->sp >= stack->sp_max )
stack_expand(stack);
@@ -2549,35 +2552,18 @@ void script_free_code(struct script_code* code)
/*==========================================
* コマンドの読み取り
*------------------------------------------*/
-static int unget_com_data=-1;
-int get_com(unsigned char *script,int *pos)
+c_op get_com(unsigned char *script,int *pos)
{
- int i,j;
- if(unget_com_data>=0){
- i=unget_com_data;
- unget_com_data=-1;
- return i;
- }
+ int i = 0, j = 0;
+
if(script[*pos]>=0x80){
return C_INT;
}
- i=0; j=0;
while(script[*pos]>=0x40){
i=script[(*pos)++]<<j;
j+=6;
}
- return i+(script[(*pos)++]<<j);
-}
-
-/*==========================================
- * コマンドのプッシュバック
- *------------------------------------------*/
-void unget_com(int c)
-{
- if(unget_com_data!=-1)
- ShowError("unget_com can back only 1 data\n");
-
- unget_com_data=c;
+ return (c_op)(i+(script[(*pos)++]<<j));
}
/*==========================================
@@ -2970,14 +2956,14 @@ void run_script(struct script_code *rootscript,int pos,int rid,int oid)
//Resume script.
st = sd->st;
} else {
- st = aCalloc(sizeof(struct script_state), 1);
+ st = (struct script_state*)aCalloc(sizeof(struct script_state), 1);
// the script is different, make new script_state and stack
- st->stack = aMalloc (sizeof(struct script_stack));
+ st->stack = (struct script_stack*)aMalloc (sizeof(struct script_stack));
st->stack->sp=0;
st->stack->sp_max=64;
st->stack->stack_data = (struct script_data *)aCalloc(st->stack->sp_max,sizeof(st->stack->stack_data[0]));
st->stack->defsp = st->stack->sp;
- st->stack->var_function = aCalloc(1, sizeof(struct linkdb_node*));
+ st->stack->var_function = (struct linkdb_node**)aCalloc(1, sizeof(struct linkdb_node*));
st->state = RUN;
st->script = rootscript;
}
@@ -3056,7 +3042,6 @@ int run_script_timer(int tid, unsigned int tick, int id, int data)
*------------------------------------------*/
void run_script_main(struct script_state *st)
{
- int c;
int cmdcount=script_config.check_cmdcount;
int gotocount=script_config.check_gotocount;
TBL_PC *sd;
@@ -3084,8 +3069,9 @@ void run_script_main(struct script_state *st)
} else if(st->state != END)
st->state = RUN;
- while(st->state == RUN){
- c= get_com(st->script->script_buf,&st->pos);
+ while(st->state == RUN)
+ {
+ enum c_op c = get_com(st->script->script_buf,&st->pos);
switch(c){
case C_EOL:
if( stack->sp != stack->defsp )
@@ -3623,7 +3609,7 @@ int do_init_script()
mapreg_db= idb_alloc(DB_OPT_BASE);
mapregstr_db=idb_alloc(DB_OPT_RELEASE_DATA);
userfunc_db=strdb_alloc(DB_OPT_DUP_KEY,0);
- scriptlabel_db=strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_ALLOW_NULL_DATA,50);
+ scriptlabel_db=strdb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_ALLOW_NULL_DATA),50);
script_load_mapreg();
@@ -4039,7 +4025,7 @@ BUILDIN_FUNC(callfunc)
struct script_code *scr, *oldscr;
const char* str = script_getstr(st,2);
- scr = strdb_get(userfunc_db, str);
+ scr = (struct script_code*)strdb_get(userfunc_db, str);
if( !scr )
{
ShowError("script:callfunc: function not found! [%s]\n", str);
@@ -8097,12 +8083,12 @@ BUILDIN_FUNC(hideonnpc)
BUILDIN_FUNC(sc_start)
{
struct block_list* bl;
- int type;
+ enum sc_type type;
int tick;
int val1;
int val4 = 0;
- type = script_getnum(st,2);
+ type = (sc_type)script_getnum(st,2);
tick = script_getnum(st,3);
val1 = script_getnum(st,4);
if( script_hasdata(st,5) )
@@ -8110,7 +8096,7 @@ BUILDIN_FUNC(sc_start)
else
bl = map_id2bl(st->rid);
- if( tick == 0 && val1 > 0 && type >= 0 && type < SC_MAX && status_sc2skill(type) != 0 )
+ if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status_sc2skill(type) != 0 )
{// When there isn't a duration specified, try to get it from the skill_db
tick = skill_get_time(status_sc2skill(type), val1);
}
@@ -8124,6 +8110,7 @@ BUILDIN_FUNC(sc_start)
if( bl )
status_change_start(bl, type, 10000, val1, 0, 0, val4, tick, 2);
+
return 0;
}
@@ -8133,13 +8120,13 @@ BUILDIN_FUNC(sc_start)
BUILDIN_FUNC(sc_start2)
{
struct block_list* bl;
- int type;
+ enum sc_type type;
int tick;
int val1;
int val4 = 0;
int rate;
- type = script_getnum(st,2);
+ type = (sc_type)script_getnum(st,2);
tick = script_getnum(st,3);
val1 = script_getnum(st,4);
rate = script_getnum(st,5);
@@ -8148,7 +8135,7 @@ BUILDIN_FUNC(sc_start2)
else
bl = map_id2bl(st->rid);
- if( tick == 0 && val1 > 0 && type >= 0 && type < SC_MAX && status_sc2skill(type) != 0 )
+ if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status_sc2skill(type) != 0 )
{// When there isn't a duration specified, try to get it from the skill_db
tick = skill_get_time(status_sc2skill(type), val1);
}
@@ -8172,14 +8159,14 @@ BUILDIN_FUNC(sc_start2)
BUILDIN_FUNC(sc_start4)
{
struct block_list* bl;
- int type;
+ enum sc_type type;
int tick;
int val1;
int val2;
int val3;
int val4;
- type = script_getnum(st,2);
+ type = (sc_type)script_getnum(st,2);
tick = script_getnum(st,3);
val1 = script_getnum(st,4);
val2 = script_getnum(st,5);
@@ -8190,7 +8177,7 @@ BUILDIN_FUNC(sc_start4)
else
bl = map_id2bl(st->rid);
- if( tick == 0 && val1 > 0 && type >= 0 && type < SC_MAX && status_sc2skill(type) != 0 )
+ if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status_sc2skill(type) != 0 )
{// When there isn't a duration specified, try to get it from the skill_db
tick = skill_get_time(status_sc2skill(type), val1);
}
@@ -8235,7 +8222,7 @@ BUILDIN_FUNC(sc_end)
if (!sce) return 0;
//This should help status_change_end force disabling the SC in case it has no limit.
sce->val1 = sce->val2 = sce->val3 = sce->val4 = 0;
- status_change_end(bl, type, INVALID_TIMER);
+ status_change_end(bl, (sc_type)type, INVALID_TIMER);
} else
status_change_clear(bl, 2);// remove all effects
return 0;
@@ -8257,7 +8244,7 @@ BUILDIN_FUNC(getscrate)
bl = map_id2bl(st->rid);
if (bl)
- rate = status_get_sc_def(bl,type, 10000, 10000, 0);
+ rate = status_get_sc_def(bl, (sc_type)type, 10000, 10000, 0);
script_pushint(st,rate);
return 0;
@@ -9193,7 +9180,7 @@ BUILDIN_FUNC(getcastlename)
{
const char* mapname = mapindex_getmapname(script_getstr(st,2),NULL);
struct guild_castle* gc = guild_mapname2gc(mapname);
- char* name = (gc) ? gc->castle_name : "";
+ const char* name = (gc) ? gc->castle_name : "";
script_pushstrcopy(st,name);
return 0;
}
@@ -10309,9 +10296,8 @@ BUILDIN_FUNC(petrecovery)
} else //Init
pd->recovery = (struct pet_recovery *)aMalloc(sizeof(struct pet_recovery));
- pd->recovery->type=script_getnum(st,2);
+ pd->recovery->type=(sc_type)script_getnum(st,2);
pd->recovery->delay=script_getnum(st,3);
-
pd->recovery->timer=-1;
return 0;
@@ -10484,11 +10470,13 @@ BUILDIN_FUNC(npcskilleffect)
BUILDIN_FUNC(specialeffect)
{
struct block_list *bl=map_id2bl(st->oid);
+ int type = script_getnum(st,2);
+ enum send_target target = script_hasdata(st,3) ? (send_target)script_getnum(st,3) : AREA;
if(bl==NULL)
return 0;
- clif_specialeffect(bl,script_getnum(st,2), (script_hasdata(st,3)?script_getnum(st,3):AREA));
+ clif_specialeffect(bl, type, target);
return 0;
}
@@ -10496,11 +10484,13 @@ BUILDIN_FUNC(specialeffect)
BUILDIN_FUNC(specialeffect2)
{
TBL_PC *sd=script_rid2sd(st);
+ int type = script_getnum(st,2);
+ enum send_target target = script_hasdata(st,3) ? (send_target)script_getnum(st,3) : AREA;
if(sd==NULL)
return 0;
- clif_specialeffect(&sd->bl,script_getnum(st,2), (script_hasdata(st,3)?script_getnum(st,3):AREA));
+ clif_specialeffect(&sd->bl, type, target);
return 0;
}
@@ -11651,7 +11641,7 @@ BUILDIN_FUNC(checkcell)
const char *map = script_getstr(st, 2);
m = mapindex_name2id(map);
if(m){
- script_pushint(st,map_getcell(m, script_getnum(st,3), script_getnum(st,4),script_getnum(st,5)));
+ script_pushint(st,map_getcell(m, script_getnum(st,3), script_getnum(st,4),(cell_chk)script_getnum(st,5)));
} else {
script_pushint(st,0);
}
@@ -11831,7 +11821,7 @@ BUILDIN_FUNC(escape_sql)
str = script_getstr(st,2);
len = strlen(str);
- esc_str = aMallocA(len*2+1);
+ esc_str = (char*)aMallocA(len*2+1);
#if defined(TXT_ONLY)
jstrescapecpy(esc_str, str);
#else
diff --git a/src/map/script.h b/src/map/script.h
index b9e5fdb01..943ce3a4d 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -25,7 +25,7 @@ extern struct Script_Config {
const char *joblvup_event_name;
} script_config;
-enum c_op {
+typedef enum c_op {
C_NOP, // end of script/no value (nil)
C_POS,
C_INT, // number
@@ -63,7 +63,7 @@ enum c_op {
C_NOT, // ~ a
C_R_SHIFT, // a >> b
C_L_SHIFT // a << b
-};
+} c_op;
struct script_data {
enum c_op type;
diff --git a/src/map/skill.c b/src/map/skill.c
index 3095874f4..df5c8deff 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -408,6 +408,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, int
struct status_data *sstatus, *tstatus;
struct status_change *sc, *tsc;
+ enum sc_type status;
int skill;
int rate;
@@ -523,9 +524,9 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, int
break;
case AS_GRIMTOOTH:
- skill = dstsd?SC_SLOWDOWN:SC_STOP;
- if (!tsc->data[skill])
- sc_start(bl,skill,100,skilllv,skill_get_time2(skillid, skilllv));
+ status = dstsd?SC_SLOWDOWN:SC_STOP;
+ if (!tsc->data[status])
+ sc_start(bl,status,100,skilllv,skill_get_time2(skillid, skilllv));
break;
case WZ_FIREPILLAR:
@@ -705,9 +706,9 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, int
break;
case LK_JOINTBEAT:
- skill = status_skill2sc(skillid);
+ status = status_skill2sc(skillid);
if (tsc->jb_flag) {
- sc_start2(bl,skill,(5*skilllv+5),skilllv,tsc->jb_flag&BREAK_FLAGS,skill_get_time2(skillid,skilllv));
+ sc_start2(bl,status,(5*skilllv+5),skilllv,tsc->jb_flag&BREAK_FLAGS,skill_get_time2(skillid,skilllv));
tsc->jb_flag = 0;
}
break;
@@ -807,7 +808,8 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, int
skillid != CR_REFLECTSHIELD &&
skillid != ASC_BREAKER
){ //Trigger status effects
- int i, type;
+ enum sc_type type;
+ int i;
for(i=0; i < ARRAYLENGTH(sd->addeff) && sd->addeff[i].flag; i++)
{
rate = sd->addeff[i].rate;
@@ -998,7 +1000,8 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list *
if(dstsd && attack_type&BF_WEAPON)
{ //Counter effects.
- int i, type, time;
+ enum sc_type type;
+ int i, time;
for(i=0; i < ARRAYLENGTH(dstsd->addeff2) && dstsd->addeff2[i].flag; i++)
{
rate = dstsd->addeff2[i].rate;
@@ -1104,9 +1107,9 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list *
--------------------------------------------------------------------------*/
int skill_break_equip (struct block_list *bl, unsigned short where, int rate, int flag)
{
- const int where_list[4] = {EQP_WEAPON, EQP_ARMOR, EQP_SHIELD, EQP_HELM};
- const int scatk[4] = {SC_STRIPWEAPON, SC_STRIPARMOR, SC_STRIPSHIELD, SC_STRIPHELM};
- const int scdef[4] = {SC_CP_WEAPON, SC_CP_ARMOR, SC_CP_SHIELD, SC_CP_HELM};
+ const int where_list[4] = {EQP_WEAPON, EQP_ARMOR, EQP_SHIELD, EQP_HELM};
+ const enum sc_type scatk[4] = {SC_STRIPWEAPON, SC_STRIPARMOR, SC_STRIPSHIELD, SC_STRIPHELM};
+ const enum sc_type scdef[4] = {SC_CP_WEAPON, SC_CP_ARMOR, SC_CP_SHIELD, SC_CP_HELM};
struct status_change *sc = status_get_sc(bl);
int i,j;
TBL_PC *sd;
@@ -1188,9 +1191,9 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in
int skill_strip_equip(struct block_list *bl, unsigned short where, int rate, int lv, int time)
{
struct status_change *sc;
- const int pos[4] = {EQP_WEAPON, EQP_SHIELD, EQP_ARMOR, EQP_HELM};
- const int sc_atk[4] = {SC_STRIPWEAPON, SC_STRIPSHIELD, SC_STRIPARMOR, SC_STRIPHELM};
- const int sc_def[4] = {SC_CP_WEAPON, SC_CP_SHIELD, SC_CP_ARMOR, SC_CP_HELM};
+ const int pos[4] = {EQP_WEAPON, EQP_SHIELD, EQP_ARMOR, EQP_HELM};
+ const enum sc_type sc_atk[4] = {SC_STRIPWEAPON, SC_STRIPSHIELD, SC_STRIPARMOR, SC_STRIPHELM};
+ const enum sc_type sc_def[4] = {SC_CP_WEAPON, SC_CP_SHIELD, SC_CP_ARMOR, SC_CP_HELM};
int i;
if (rand()%100 >= rate)
@@ -2810,7 +2813,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
struct status_change_entry *tsce;
struct mob_data *md;
struct mob_data *dstmd;
- int i,type;
+ int i;
+ enum sc_type type;
if(skillid > 0 && skilllv <= 0) return 0; // celest
@@ -3109,9 +3113,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
mob_class_change(dstmd,class_);
if( tsc && dstmd->status.mode&MD_BOSS )
{
- const int scs[] = { SC_QUAGMIRE, SC_PROVOKE, SC_ROKISWEIL, SC_GRAVITATION, SC_SUITON, SC_STRIPWEAPON, SC_STRIPSHIELD, SC_STRIPARMOR, SC_STRIPHELM, SC_BLADESTOP };
+ const enum sc_type scs[] = { SC_QUAGMIRE, SC_PROVOKE, SC_ROKISWEIL, SC_GRAVITATION, SC_SUITON, SC_STRIPWEAPON, SC_STRIPSHIELD, SC_STRIPARMOR, SC_STRIPHELM, SC_BLADESTOP };
for (i = SC_COMMON_MIN; i <= SC_COMMON_MAX; i++)
- if (tsc->data[i]) status_change_end(bl, i, -1);
+ if (tsc->data[i]) status_change_end(bl, (sc_type)i, -1);
for (i = 0; i < ARRAYLENGTH(scs); i++)
if (tsc->data[scs[i]]) status_change_end(bl, scs[i], -1);
}
@@ -3153,7 +3157,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
case CG_MARIONETTE:
{
struct status_change *sc= status_get_sc(src);
- int type2 = SC_MARIONETTE2;
+ enum sc_type type2 = SC_MARIONETTE2;
if(sc && tsc){
if (!sc->data[type] && !tsc->data[type2]) {
@@ -4020,32 +4024,36 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
case RG_STRIPARMOR:
case RG_STRIPHELM:
case ST_FULLSTRIP:
+ {
+ unsigned short location = 0;
i = 5+2*skilllv;
if (sstatus->dex > tstatus->dex)
i += (sstatus->dex - tstatus->dex)/5;
+
switch (skillid) {
case RG_STRIPWEAPON:
- type = EQP_WEAPON;
+ location = EQP_WEAPON;
break;
case RG_STRIPSHIELD:
- type = EQP_SHIELD;
+ location = EQP_SHIELD;
break;
case RG_STRIPARMOR:
- type = EQP_ARMOR;
+ location = EQP_ARMOR;
break;
case RG_STRIPHELM:
- type = EQP_HELM;
+ location = EQP_HELM;
break;
case ST_FULLSTRIP:
- type = EQP_WEAPON|EQP_SHIELD|EQP_ARMOR|EQP_HELM;
+ location = EQP_WEAPON|EQP_SHIELD|EQP_ARMOR|EQP_HELM;
break;
}
//Note that Full Strip autospell doesn't use a duration
if (!clif_skill_nodamage(src,bl,skillid,skilllv,
- skill_strip_equip(bl, type, i, skilllv,
+ skill_strip_equip(bl, location, i, skilllv,
sd&&skillid==ST_FULLSTRIP&&!pc_checkskill(sd, skillid)?0:skill_get_time(skillid,skilllv)))
&& sd)
clif_skill_fail(sd,skillid,0,0); //Nothing stripped.
+ }
break;
case AM_BERSERKPITCHER:
@@ -4139,7 +4147,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
case AM_CP_ARMOR:
case AM_CP_HELM:
{
- int scid = SC_STRIPWEAPON + (skillid - AM_CP_WEAPON);
+ enum sc_type scid = (sc_type)(SC_STRIPWEAPON + (skillid - AM_CP_WEAPON));
if(tsc && tsc->data[scid])
status_change_end(bl, scid, -1 );
clif_skill_nodamage(src,bl,skillid,skilllv,
@@ -4192,7 +4200,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
}
if(status_isimmune(bl) || !tsc || !tsc->count)
break;
- for(i=0;i<SC_MAX;i++){
+ for(i=0;i<SC_MAX;i++)
+ {
if (!tsc->data[i])
continue;
switch (i) {
@@ -4217,7 +4226,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
continue;
}
if(i==SC_BERSERK) tsc->data[i]->val2=0; //Mark a dispelled berserk to avoid setting hp to 100 by setting hp penalty to 0.
- status_change_end(bl,i,-1);
+ status_change_end(bl,(sc_type)i,-1);
}
break;
}
@@ -4446,7 +4455,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
if (i > SC_ASPDPOTION3)
i = SC_ASPDPOTION3;
clif_skill_nodamage(src,bl,skillid,skilllv,
- sc_start(bl,i,100,skilllv,skilllv * 60000));
+ sc_start(bl,(sc_type)i,100,skilllv,skilllv * 60000));
}
break;
@@ -4764,8 +4773,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
}
for (i=0; i<4; i++) {
if(tsc->data[SC_STRIPWEAPON + i])
- status_change_end(bl, SC_STRIPWEAPON + i, -1 );
- sc_start(bl,SC_CP_WEAPON + i,100,skilllv,skilltime);
+ status_change_end(bl, (sc_type)(SC_STRIPWEAPON + i), -1 );
+ sc_start(bl,(sc_type)(SC_CP_WEAPON + i),100,skilllv,skilltime);
}
clif_skill_nodamage(src,bl,skillid,skilllv,1);
}
@@ -4831,7 +4840,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
break;
case 7: // stop freeze or stoned
{
- int sc[] = { SC_STOP, SC_FREEZE, SC_STONE };
+ enum sc_type sc[] = { SC_STOP, SC_FREEZE, SC_STONE };
sc_start(bl,sc[rand()%3],100,skilllv,skill_get_time2(skillid,skilllv));
}
break;
@@ -5120,7 +5129,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
case NPC_DRAGONFEAR:
if (flag&1) {
- const int sc[] = { SC_STUN, SC_CURSE, SC_SILENCE, SC_BLEEDING };
+ const enum sc_type sc[] = { SC_STUN, SC_CURSE, SC_SILENCE, SC_BLEEDING };
i = rand()%ARRAYLENGTH(sc);
sc_start(bl,sc[i],100,skilllv,skill_get_time2(skillid,i+1));
} else {
@@ -5528,7 +5537,8 @@ int skill_castend_pos2(struct block_list* src, int x, int y, int skillid, int sk
struct status_change* sc;
struct status_change_entry *sce;
struct skill_unit_group* sg;
- int i,type;
+ enum sc_type type;
+ int i;
//if(skilllv <= 0) return 0;
if(skillid > 0 && skilllv <= 0) return 0; // celest
@@ -6491,7 +6501,8 @@ static int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, un
struct block_list *ss;
struct status_change *sc;
struct status_change_entry *sce;
- int type,skillid;
+ enum sc_type type;
+ int skillid;
nullpo_retr(0, src);
nullpo_retr(0, bl);
@@ -6651,7 +6662,8 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
struct status_data *tstatus, *sstatus;
struct status_change *tsc, *sc;
struct skill_unit_group_tickset *ts;
- int type, skillid;
+ enum sc_type type;
+ int skillid;
int diff=0;
nullpo_retr(0, src);
@@ -6926,60 +6938,61 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
break;
if (battle_check_target(ss,bl,BCT_PARTY)>0)
{ // Support Effect only on party, not guild
+ int heal;
int i = rand()%13; // Positive buff count
- type = skill_get_time2(sg->skill_id, sg->skill_lv); //Duration
+ int time = skill_get_time2(sg->skill_id, sg->skill_lv); //Duration
switch (i)
{
case 0: // Heal 1~9999 HP
- type = rand() %9999+1;
- clif_skill_nodamage(ss,bl,AL_HEAL,type,1);
- status_heal(bl,type,0,0);
+ heal = rand() %9999+1;
+ clif_skill_nodamage(ss,bl,AL_HEAL,heal,1);
+ status_heal(bl,heal,0,0);
break;
case 1: // End all negative status
status_change_clear_buffs(bl,2);
if (tsd) clif_gospel_info(tsd, 0x15);
break;
case 2: // Immunity to all status
- sc_start(bl,SC_SCRESIST,100,100,type);
+ sc_start(bl,SC_SCRESIST,100,100,time);
if (tsd) clif_gospel_info(tsd, 0x16);
break;
case 3: // MaxHP +100%
- sc_start(bl,SC_INCMHPRATE,100,100,type);
+ sc_start(bl,SC_INCMHPRATE,100,100,time);
if (tsd) clif_gospel_info(tsd, 0x17);
break;
case 4: // MaxSP +100%
- sc_start(bl,SC_INCMSPRATE,100,100,type);
+ sc_start(bl,SC_INCMSPRATE,100,100,time);
if (tsd) clif_gospel_info(tsd, 0x18);
break;
case 5: // All stats +20
- sc_start(bl,SC_INCALLSTATUS,100,20,type);
+ sc_start(bl,SC_INCALLSTATUS,100,20,time);
if (tsd) clif_gospel_info(tsd, 0x19);
break;
case 6: // Level 10 Blessing
- sc_start(bl,SC_BLESSING,100,10,type);
+ sc_start(bl,SC_BLESSING,100,10,time);
break;
case 7: // Level 10 Increase AGI
- sc_start(bl,SC_INCREASEAGI,100,10,type);
+ sc_start(bl,SC_INCREASEAGI,100,10,time);
break;
case 8: // Enchant weapon with Holy element
- sc_start(bl,SC_ASPERSIO,100,1,type);
+ sc_start(bl,SC_ASPERSIO,100,1,time);
if (tsd) clif_gospel_info(tsd, 0x1c);
break;
case 9: // Enchant armor with Holy element
- sc_start(bl,SC_BENEDICTIO,100,1,type);
+ sc_start(bl,SC_BENEDICTIO,100,1,time);
if (tsd) clif_gospel_info(tsd, 0x1d);
break;
case 10: // DEF +25%
- sc_start(bl,SC_INCDEFRATE,100,25,type);
+ sc_start(bl,SC_INCDEFRATE,100,25,time);
if (tsd) clif_gospel_info(tsd, 0x1e);
break;
case 11: // ATK +100%
- sc_start(bl,SC_INCATKRATE,100,100,type);
+ sc_start(bl,SC_INCATKRATE,100,100,time);
if (tsd) clif_gospel_info(tsd, 0x1f);
break;
case 12: // HIT/Flee +50
- sc_start(bl,SC_INCHIT,100,50,type);
- sc_start(bl,SC_INCFLEE,100,50,type);
+ sc_start(bl,SC_INCHIT,100,50,time);
+ sc_start(bl,SC_INCFLEE,100,50,time);
if (tsd) clif_gospel_info(tsd, 0x20);
break;
}
@@ -6987,35 +7000,35 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
else if (battle_check_target(&src->bl,bl,BCT_ENEMY)>0)
{ // Offensive Effect
int i = rand()%9; // Negative buff count
- type = skill_get_time2(sg->skill_id, sg->skill_lv);
+ int time = skill_get_time2(sg->skill_id, sg->skill_lv);
switch (i)
{
case 0: // Deal 1~9999 damage
skill_attack(BF_MISC,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0);
break;
case 1: // Curse
- sc_start(bl,SC_CURSE,100,1,type);
+ sc_start(bl,SC_CURSE,100,1,time);
break;
case 2: // Blind
- sc_start(bl,SC_BLIND,100,1,type);
+ sc_start(bl,SC_BLIND,100,1,time);
break;
case 3: // Poison
- sc_start(bl,SC_POISON,100,1,type);
+ sc_start(bl,SC_POISON,100,1,time);
break;
case 4: // Level 10 Provoke
- sc_start(bl,SC_PROVOKE,100,10,type);
+ sc_start(bl,SC_PROVOKE,100,10,time);
break;
case 5: // DEF -100%
- sc_start(bl,SC_INCDEFRATE,100,-100,type);
+ sc_start(bl,SC_INCDEFRATE,100,-100,time);
break;
case 6: // ATK -100%
- sc_start(bl,SC_INCATKRATE,100,-100,type);
+ sc_start(bl,SC_INCATKRATE,100,-100,time);
break;
case 7: // Flee -100%
- sc_start(bl,SC_INCFLEERATE,100,-100,type);
+ sc_start(bl,SC_INCFLEERATE,100,-100,time);
break;
case 8: // Speed/ASPD -25%
- sc_start4(bl,SC_GOSPEL,100,1,0,0,BCT_ENEMY,type);
+ sc_start4(bl,SC_GOSPEL,100,1,0,0,BCT_ENEMY,time);
break;
}
}
@@ -7063,7 +7076,7 @@ int skill_unit_onout (struct skill_unit *src, struct block_list *bl, unsigned in
struct skill_unit_group *sg;
struct status_change *sc;
struct status_change_entry *sce;
- int type;
+ enum sc_type type;
nullpo_retr(0, src);
nullpo_retr(0, bl);
@@ -7110,7 +7123,7 @@ static int skill_unit_onleft (int skill_id, struct block_list *bl, unsigned int
{
struct status_change *sc;
struct status_change_entry *sce;
- int type;
+ enum sc_type type;
sc = status_get_sc(bl);
if (sc && !sc->count)
diff --git a/src/map/status.c b/src/map/status.c
index a87e2cbc4..47d2617b6 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -60,22 +60,22 @@ int current_equip_card_id; //To prevent card-stacking (from jA) [Skotlex]
//we need it for new cards 15 Feb 2005, to check if the combo cards are insrerted into the CURRENT weapon only
//to avoid cards exploits
-static int SkillStatusChangeTable[MAX_SKILL]; // skill -> status
-static int StatusIconChangeTable[SC_MAX]; // status -> icon
-unsigned long StatusChangeFlagTable[SC_MAX]; // status -> flags
-static int StatusSkillChangeTable[SC_MAX]; // status -> skill
+static sc_type SkillStatusChangeTable[MAX_SKILL]; // skill -> status
+static int StatusIconChangeTable[SC_MAX]; // status -> icon
+unsigned long StatusChangeFlagTable[SC_MAX]; // status -> flags
+static int StatusSkillChangeTable[SC_MAX]; // status -> skill
-int status_skill2sc(int skill)
+sc_type status_skill2sc(int skill)
{
int sk = skill_get_index(skill);
if( sk == 0 ) {
ShowError("status_skill2sc: Unsupported skill id %d\n", skill);
- return -1;
+ return SC_NONE;
}
return SkillStatusChangeTable[sk];
}
-int status_sc2skill(int sc)
+int status_sc2skill(sc_type sc)
{
if( sc < 0 || sc >= SC_MAX ) {
ShowError("status_skill2sc: Unsupported status change id %d\n", sc);
@@ -87,7 +87,7 @@ int status_sc2skill(int sc)
#define add_sc(skill,sc) set_sc(skill,sc,SI_BLANK,SCB_NONE)
-static void set_sc(int skill, int sc, int icon, unsigned int flag)
+static void set_sc(int skill, sc_type sc, int icon, unsigned int flag)
{
int sk = skill_get_index(skill);
if( sk == 0 ) {
@@ -105,7 +105,7 @@ static void set_sc(int skill, int sc, int icon, unsigned int flag)
StatusIconChangeTable[sc] = icon;
StatusChangeFlagTable[sc] |= flag;
- if( SkillStatusChangeTable[sk] == -1 )
+ if( SkillStatusChangeTable[sk] == SC_NONE )
SkillStatusChangeTable[sk] = sc;
}
@@ -115,7 +115,7 @@ void initChangeTables(void)
for (i = 0; i < SC_MAX; i++)
StatusIconChangeTable[i] = SI_BLANK;
for (i = 0; i < MAX_SKILL; i++)
- SkillStatusChangeTable[i] = -1;
+ SkillStatusChangeTable[i] = SC_NONE;
memset(StatusSkillChangeTable, 0, sizeof(StatusSkillChangeTable));
memset(StatusChangeFlagTable, 0, sizeof(StatusChangeFlagTable));
@@ -407,21 +407,21 @@ void initChangeTables(void)
set_sc( GD_REGENERATION , SC_REGENERATION , SI_BLANK , SCB_REGEN );
// Storing the target job rather than simply SC_SPIRIT simplifies code later on.
- SkillStatusChangeTable[SL_ALCHEMIST] = MAPID_ALCHEMIST,
- SkillStatusChangeTable[SL_MONK] = MAPID_MONK,
- SkillStatusChangeTable[SL_STAR] = MAPID_STAR_GLADIATOR,
- SkillStatusChangeTable[SL_SAGE] = MAPID_SAGE,
- SkillStatusChangeTable[SL_CRUSADER] = MAPID_CRUSADER,
- SkillStatusChangeTable[SL_SUPERNOVICE] = MAPID_SUPER_NOVICE,
- SkillStatusChangeTable[SL_KNIGHT] = MAPID_KNIGHT,
- SkillStatusChangeTable[SL_WIZARD] = MAPID_WIZARD,
- SkillStatusChangeTable[SL_PRIEST] = MAPID_PRIEST,
- SkillStatusChangeTable[SL_BARDDANCER] = MAPID_BARDDANCER,
- SkillStatusChangeTable[SL_ROGUE] = MAPID_ROGUE,
- SkillStatusChangeTable[SL_ASSASIN] = MAPID_ASSASSIN,
- SkillStatusChangeTable[SL_BLACKSMITH] = MAPID_BLACKSMITH,
- SkillStatusChangeTable[SL_HUNTER] = MAPID_HUNTER,
- SkillStatusChangeTable[SL_SOULLINKER] = MAPID_SOUL_LINKER,
+ SkillStatusChangeTable[SL_ALCHEMIST] = (sc_type)MAPID_ALCHEMIST,
+ SkillStatusChangeTable[SL_MONK] = (sc_type)MAPID_MONK,
+ SkillStatusChangeTable[SL_STAR] = (sc_type)MAPID_STAR_GLADIATOR,
+ SkillStatusChangeTable[SL_SAGE] = (sc_type)MAPID_SAGE,
+ SkillStatusChangeTable[SL_CRUSADER] = (sc_type)MAPID_CRUSADER,
+ SkillStatusChangeTable[SL_SUPERNOVICE] = (sc_type)MAPID_SUPER_NOVICE,
+ SkillStatusChangeTable[SL_KNIGHT] = (sc_type)MAPID_KNIGHT,
+ SkillStatusChangeTable[SL_WIZARD] = (sc_type)MAPID_WIZARD,
+ SkillStatusChangeTable[SL_PRIEST] = (sc_type)MAPID_PRIEST,
+ SkillStatusChangeTable[SL_BARDDANCER] = (sc_type)MAPID_BARDDANCER,
+ SkillStatusChangeTable[SL_ROGUE] = (sc_type)MAPID_ROGUE,
+ SkillStatusChangeTable[SL_ASSASIN] = (sc_type)MAPID_ASSASSIN,
+ SkillStatusChangeTable[SL_BLACKSMITH] = (sc_type)MAPID_BLACKSMITH,
+ SkillStatusChangeTable[SL_HUNTER] = (sc_type)MAPID_HUNTER,
+ SkillStatusChangeTable[SL_SOULLINKER] = (sc_type)MAPID_SOUL_LINKER,
//Status that don't have a skill associated.
StatusIconChangeTable[SC_WEIGHT50] = SI_WEIGHT50;
@@ -1350,7 +1350,7 @@ int status_calc_mob(struct mob_data* md, int first)
return 0;
}
if (!md->base_status)
- md->base_status = aCalloc(1, sizeof(struct status_data));
+ md->base_status = (struct status_data*)aCalloc(1, sizeof(struct status_data));
status = md->base_status;
memcpy(status, &md->db->status, sizeof(struct status_data));
@@ -4603,7 +4603,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
sc = status_get_sc(bl);
status = status_get_status_data(bl);
- if( type < 0 || type >= SC_MAX )
+ if( type <= SC_NONE || type >= SC_MAX )
{
ShowError("status_change_start: invalid status change (%d)!\n", type);
return 0;
@@ -5581,8 +5581,8 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
{ //Try to inherit the status from the Crusader [Skotlex]
//Ideally, we should calculate the remaining time and use that, but we'll trust that
//once the Crusader's status changes, it will reflect on the others.
- const int types[] = { SC_AUTOGUARD, SC_DEFENDER, SC_REFLECTSHIELD, SC_ENDURE };
- int type2;
+ const enum sc_type types[] = { SC_AUTOGUARD, SC_DEFENDER, SC_REFLECTSHIELD, SC_ENDURE };
+ enum sc_type type2;
int i = map_flag_gvg(bl->m)?2:3;
while (i >= 0) {
type2 = types[i];
@@ -6166,7 +6166,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
int status_change_clear(struct block_list* bl, int type)
{
struct status_change* sc;
- enum sc_type i;
+ int i;
sc = status_get_sc(bl);
@@ -6200,7 +6200,7 @@ int status_change_clear(struct block_list* bl, int type)
continue;
}
- status_change_end(bl, i, INVALID_TIMER);
+ status_change_end(bl, (sc_type)i, INVALID_TIMER);
if( type == 1 && sc->data[i] )
{ //If for some reason status_change_end decides to still keep the status when quitting. [Skotlex]
@@ -6442,7 +6442,7 @@ int status_change_end(struct block_list* bl, enum sc_type type, int tid)
case SC_MARIONETTE2: /// Marionette target
if (sce->val1)
{ // check for partner and end their marionette status as well
- int type2 = (type == SC_MARIONETTE) ? SC_MARIONETTE2 : SC_MARIONETTE;
+ enum sc_type type2 = (type == SC_MARIONETTE) ? SC_MARIONETTE2 : SC_MARIONETTE;
struct block_list *pbl = map_id2bl(sce->val1);
struct status_change* sc2 = pbl?status_get_sc(pbl):NULL;
@@ -6728,7 +6728,7 @@ int kaahi_heal_timer(int tid, unsigned int tick, int id, int data)
*------------------------------------------*/
int status_change_timer(int tid, unsigned int tick, int id, int data)
{
- enum sc_type type = data;
+ enum sc_type type = (sc_type)data;
struct block_list *bl;
struct map_session_data *sd;
struct status_data *status;
@@ -7074,7 +7074,7 @@ int status_change_timer_sub(struct block_list* bl, va_list ap)
struct block_list* src = va_arg(ap,struct block_list*);
struct status_change_entry* sce = va_arg(ap,struct status_change_entry*);
- enum sc_type type = va_arg(ap,enum sc_type);
+ enum sc_type type = (sc_type)va_arg(ap,int); //gcc: enum args get promoted to int
unsigned int tick = va_arg(ap,unsigned int);
if (status_isdead(bl))
@@ -7129,7 +7129,7 @@ int status_change_timer_sub(struct block_list* bl, va_list ap)
*------------------------------------------*/
int status_change_clear_buffs (struct block_list* bl, int type)
{
- enum sc_type i;
+ int i;
struct status_change *sc= status_get_sc(bl);
if (!sc || !sc->count)
@@ -7139,7 +7139,7 @@ int status_change_clear_buffs (struct block_list* bl, int type)
for( i = SC_COMMON_MIN; i <= SC_COMMON_MAX; i++ )
{
if(sc->data[i])
- status_change_end(bl,i,-1);
+ status_change_end(bl,(sc_type)i,-1);
}
for( i = SC_COMMON_MAX+1; i < SC_MAX; i++ )
@@ -7206,7 +7206,7 @@ int status_change_clear_buffs (struct block_list* bl, int type)
continue;
break;
}
- status_change_end(bl,i,-1);
+ status_change_end(bl,(sc_type)i,-1);
}
return 0;
}
diff --git a/src/map/status.h b/src/map/status.h
index 52274b66f..5011eada5 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -18,7 +18,9 @@ extern unsigned long StatusChangeFlagTable[];
// Status changes listing. These code are for use by the server.
-enum sc_type {
+typedef enum sc_type {
+ SC_NONE = -1,
+
//First we enumerate common status ailments which are often used around.
SC_STONE = 0,
SC_COMMON_MIN = 0, // begin
@@ -290,7 +292,7 @@ enum sc_type {
SC_SPCOST_RATE,
SC_COMMONSC_RESIST,
SC_MAX, //Automatically updated max, used in for's to check we are within bounds.
-};
+} sc_type;
//Numerates the Number for the status changes (client-dependent), imported from jA
enum si_type {
@@ -683,8 +685,8 @@ struct status_change {
};
// for looking up associated data
-int status_skill2sc(int skill);
-int status_sc2skill(int sc);
+sc_type status_skill2sc(int skill);
+int status_sc2skill(sc_type sc);
int status_damage(struct block_list *src,struct block_list *target,int hp,int sp, int walkdelay, int flag);
//Define for standard HP damage attacks.
diff --git a/src/map/storage.c b/src/map/storage.c
index 06c052d74..c2e4bf5f7 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -106,13 +106,13 @@ static void* create_storage(DBKey key, va_list args)
}
struct storage *account2storage(int account_id)
{
- return idb_ensure(storage_db,account_id,create_storage);
+ return (struct storage*)idb_ensure(storage_db,account_id,create_storage);
}
// Just to ask storage, without creation
struct storage *account2storage2(int account_id)
{
- return idb_get(storage_db, account_id);
+ return (struct storage*)idb_get(storage_db, account_id);
}
int storage_delete(int account_id)
@@ -141,7 +141,7 @@ int storage_storageopen(struct map_session_data *sd)
return 1;
}
- if((stor = idb_get(storage_db,sd->status.account_id)) == NULL)
+ if((stor = (struct storage*)idb_get(storage_db,sd->status.account_id)) == NULL)
{ //Request storage.
intif_request_storage(sd->status.account_id);
return 2;
@@ -478,7 +478,7 @@ struct guild_storage *guild2storage(int guild_id)
struct guild_storage *guild2storage2(int guild_id)
{ //For just locating a storage without creating one. [Skotlex]
- return idb_get(guild_storage_db,guild_id);
+ return (struct guild_storage*)idb_get(guild_storage_db,guild_id);
}
int guild_storage_delete(int guild_id)