summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-02-19 02:46:37 +0300
committerAndrei Karas <akaras@inbox.ru>2016-02-19 02:49:41 +0300
commitc2c1322b230dc0f564397ac68615640f1083ee56 (patch)
tree9cbdf777c0636e16963f368cb9d9fc48f094ff13 /src
parent5b74faa8afd04771af7acb918072ea71a3db475f (diff)
downloadhercules-c2c1322b230dc0f564397ac68615640f1083ee56.tar.gz
hercules-c2c1322b230dc0f564397ac68615640f1083ee56.tar.bz2
hercules-c2c1322b230dc0f564397ac68615640f1083ee56.tar.xz
hercules-c2c1322b230dc0f564397ac68615640f1083ee56.zip
Fix some cast discards 'const' qualifier from pointer target type warnings.
Add -Wcast-qual into configure comment.
Diffstat (limited to 'src')
-rw-r--r--src/char/int_guild.c14
-rw-r--r--src/common/md5calc.c6
-rw-r--r--src/common/socket.h10
-rw-r--r--src/map/atcommand.c22
-rw-r--r--src/map/battleground.c3
-rw-r--r--src/map/battleground.h2
-rw-r--r--src/map/script.c6
-rw-r--r--src/map/storage.c4
-rw-r--r--src/map/vending.c14
9 files changed, 41 insertions, 40 deletions
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index 60efeac94..c78b6b04f 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -1548,7 +1548,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
{
case GMI_POSITION:
{
- g->member[i].position=*((short *)data);
+ g->member[i].position=*((const short *)data);
g->member[i].modified = GS_MEMBER_MODIFIED;
mapif->guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
g->save_flag |= GS_MEMBER;
@@ -1557,7 +1557,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
case GMI_EXP:
{
uint64 old_exp = g->member[i].exp;
- g->member[i].exp=*((uint64 *)data);
+ g->member[i].exp=*((const uint64 *)data);
g->member[i].modified = GS_MEMBER_MODIFIED;
if (g->member[i].exp > old_exp) {
uint64 exp = g->member[i].exp - old_exp;
@@ -1582,7 +1582,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
}
case GMI_HAIR:
{
- g->member[i].hair=*((short *)data);
+ g->member[i].hair=*((const short *)data);
g->member[i].modified = GS_MEMBER_MODIFIED;
mapif->guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
g->save_flag |= GS_MEMBER; //Save new data.
@@ -1590,7 +1590,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
}
case GMI_HAIR_COLOR:
{
- g->member[i].hair_color=*((short *)data);
+ g->member[i].hair_color=*((const short *)data);
g->member[i].modified = GS_MEMBER_MODIFIED;
mapif->guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
g->save_flag |= GS_MEMBER; //Save new data.
@@ -1598,7 +1598,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
}
case GMI_GENDER:
{
- g->member[i].gender=*((short *)data);
+ g->member[i].gender=*((const short *)data);
g->member[i].modified = GS_MEMBER_MODIFIED;
mapif->guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
g->save_flag |= GS_MEMBER; //Save new data.
@@ -1606,7 +1606,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
}
case GMI_CLASS:
{
- g->member[i].class_=*((short *)data);
+ g->member[i].class_=*((const short *)data);
g->member[i].modified = GS_MEMBER_MODIFIED;
mapif->guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
g->save_flag |= GS_MEMBER; //Save new data.
@@ -1614,7 +1614,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
}
case GMI_LEVEL:
{
- g->member[i].lv=*((short *)data);
+ g->member[i].lv=*((const short *)data);
g->member[i].modified = GS_MEMBER_MODIFIED;
mapif->guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
g->save_flag |= GS_MEMBER; //Save new data.
diff --git a/src/common/md5calc.c b/src/common/md5calc.c
index 44f912992..bc70d9006 100644
--- a/src/common/md5calc.c
+++ b/src/common/md5calc.c
@@ -169,7 +169,7 @@ static void MD5_String2binary(const char * string, unsigned char * output)
//var
/*8bit*/
unsigned char padding_message[64]; //Extended message 512bit 64byte
- unsigned char *pstring; //The position of string in the present scanning notes is held.
+ const unsigned char *pstring; //The position of string in the present scanning notes is held.
/*32bit*/
unsigned int string_byte_len, //The byte chief of string is held.
@@ -192,7 +192,7 @@ static void MD5_String2binary(const char * string, unsigned char * output)
//Step 1.Append Padding Bits (extension of a mark bit)
//1-1
string_byte_len = (unsigned int)strlen(string); //The byte chief of a character sequence is acquired.
- pstring = (unsigned char *)string; //The position of the present character sequence is set.
+ pstring = (const unsigned char *)string; //The position of the present character sequence is set.
//1-2 Repeat calculation until length becomes less than 64 bytes.
for (i=string_byte_len; 64<=i; i-=64,pstring+=64)
@@ -200,7 +200,7 @@ static void MD5_String2binary(const char * string, unsigned char * output)
//1-3
copy_len = string_byte_len % 64; //The number of bytes which remained is computed.
- strncpy((char *)padding_message, (char *)pstring, copy_len); //A message is copied to an extended bit sequence.
+ strncpy((char *)padding_message, (const char *)pstring, copy_len); //A message is copied to an extended bit sequence.
memset(padding_message+copy_len, 0, 64 - copy_len); //It buries by 0 until it becomes extended bit length.
padding_message[copy_len] |= 0x80; //The next of a message is 1.
diff --git a/src/common/socket.h b/src/common/socket.h
index 70fbc3492..e1ea94f5a 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -85,11 +85,11 @@ struct config_setting_t;
#define WP2PTR(fd) WFIFO2PTR(fd)
// buffer I/O macros
-#define RBUFP(p,pos) (((uint8*)(p)) + (pos))
-#define RBUFB(p,pos) (*(uint8*)RBUFP((p),(pos)))
-#define RBUFW(p,pos) (*(uint16*)RBUFP((p),(pos)))
-#define RBUFL(p,pos) (*(uint32*)RBUFP((p),(pos)))
-#define RBUFQ(p,pos) (*(uint64*)RBUFP((p),(pos)))
+#define RBUFP(p,pos) (((const uint8*)(p)) + (pos))
+#define RBUFB(p,pos) (*(const uint8*)RBUFP((p),(pos)))
+#define RBUFW(p,pos) (*(const uint16*)RBUFP((p),(pos)))
+#define RBUFL(p,pos) (*(const uint32*)RBUFP((p),(pos)))
+#define RBUFQ(p,pos) (*(const uint64*)RBUFP((p),(pos)))
#define WBUFP(p,pos) (((uint8*)(p)) + (pos))
#define WBUFB(p,pos) (*(uint8*)WBUFP((p),(pos)))
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index eb48adc1d..4eb2051da 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -547,7 +547,7 @@ ACMD(jumpto) {
return false;
}
- if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
+ if((pl_sd=map->nick2sd((const char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
@@ -2747,7 +2747,7 @@ ACMD(recall) {
return false;
}
- if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
+ if((pl_sd=map->nick2sd((const char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
@@ -3072,7 +3072,7 @@ ACMD(kick)
return false;
}
- if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
+ if((pl_sd=map->nick2sd((const char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
@@ -5123,7 +5123,7 @@ ACMD(follow) {
return true;
}
- if ((pl_sd = map->nick2sd((char *)message)) == NULL)
+ if ((pl_sd = map->nick2sd((const char *)message)) == NULL)
{
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
@@ -5601,7 +5601,7 @@ ACMD(changegm) {
return false;
}
- if ((pl_sd=map->nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
+ if ((pl_sd=map->nick2sd((const char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
clif->message(fd, msg_fd(fd,1184)); // Target character must be online and be a guild member.
return false;
}
@@ -5621,7 +5621,7 @@ ACMD(changeleader) {
return false;
}
- if (party->changeleader(sd, map->nick2sd((char *) message)))
+ if (party->changeleader(sd, map->nick2sd((const char *) message)))
return true;
return false;
}
@@ -6380,7 +6380,7 @@ ACMD(trade) {
return false;
}
- if ( (pl_sd = map->nick2sd((char *)message)) == NULL ) {
+ if ( (pl_sd = map->nick2sd((const char *)message)) == NULL ) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
@@ -6423,7 +6423,7 @@ ACMD(unmute) {
return false;
}
- if ((pl_sd = map->nick2sd((char *)message)) == NULL)
+ if ((pl_sd = map->nick2sd((const char *)message)) == NULL)
{
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
@@ -7667,7 +7667,7 @@ ACMD(showdelay)
*------------------------------------------*/
ACMD(invite) {
unsigned int did = sd->duel_group;
- struct map_session_data *target_sd = map->nick2sd((char *)message);
+ struct map_session_data *target_sd = map->nick2sd((const char *)message);
if (did == 0)
{
@@ -7740,7 +7740,7 @@ ACMD(duel) {
duel->create(sd, maxpl);
} else {
struct map_session_data *target_sd;
- target_sd = map->nick2sd((char *)message);
+ target_sd = map->nick2sd((const char *)message);
if (target_sd != NULL) {
unsigned int newduel;
if ((newduel = duel->create(sd, 2)) != -1) {
@@ -7882,7 +7882,7 @@ ACMD(clone) {
return false;
}
- if ((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
+ if ((pl_sd=map->nick2sd((const char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
diff --git a/src/map/battleground.c b/src/map/battleground.c
index d25aef851..ae80d0fc7 100644
--- a/src/map/battleground.c
+++ b/src/map/battleground.c
@@ -495,7 +495,8 @@ void bg_config_read(void) {
}
libconfig->destroy(&bg_conf);
}
-struct bg_arena *bg_name2arena (char *name) {
+struct bg_arena *bg_name2arena(const char *name)
+{
int i;
nullpo_retr(NULL, name);
for(i = 0; i < bg->arenas; i++) {
diff --git a/src/map/battleground.h b/src/map/battleground.h
index 639d91635..bb77db125 100644
--- a/src/map/battleground.h
+++ b/src/map/battleground.h
@@ -108,7 +108,7 @@ struct battleground_interface {
void (*init) (bool minimal);
void (*final) (void);
/* */
- struct bg_arena *(*name2arena) (char *name);
+ struct bg_arena *(*name2arena) (const char *name);
void (*queue_add) (struct map_session_data *sd, struct bg_arena *arena, enum bg_queue_types type);
enum BATTLEGROUNDS_QUEUE_ACK (*can_queue) (struct map_session_data *sd, struct bg_arena *arena, enum bg_queue_types type);
int (*id2pos) (int queue_id, int account_id);
diff --git a/src/map/script.c b/src/map/script.c
index 4b3bf960c..4ae667b37 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -6651,7 +6651,7 @@ BUILDIN(getarraysize)
return true;
}
int script_array_index_cmp(const void *a, const void *b) {
- return ( *(unsigned int*)a - *(unsigned int*)b );
+ return ( *(const unsigned int*)a - *(const unsigned int*)b );
}
/// Deletes count or all the elements in an array, from the starting index.
@@ -11007,7 +11007,7 @@ BUILDIN(getstatus)
case 4: script_pushint(st, sd->sc.data[id]->val4); break;
case 5:
{
- struct TimerData* td = (struct TimerData*)timer->get(sd->sc.data[id]->timer);
+ const struct TimerData* td = (const struct TimerData*)timer->get(sd->sc.data[id]->timer);
if( td ) {
// return the amount of time remaining
@@ -19696,7 +19696,7 @@ BUILDIN(checkbound)
/* returns 0 when successful, 1 otherwise */
BUILDIN(bg_match_over) {
bool canceled = script_hasdata(st,3) ? true : false;
- struct bg_arena *arena = bg->name2arena((char*)script_getstr(st, 2));
+ struct bg_arena *arena = bg->name2arena((const char*)script_getstr(st, 2));
if( arena ) {
bg->match_over(arena,canceled);
diff --git a/src/map/storage.c b/src/map/storage.c
index f938a41ad..ceac85916 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -52,8 +52,8 @@ struct guild_storage_interface *gstorage;
*------------------------------------------*/
int storage_comp_item(const void *i1_, const void *i2_)
{
- struct item *i1 = (struct item *)i1_;
- struct item *i2 = (struct item *)i2_;
+ const struct item *i1 = (const struct item *)i1_;
+ const struct item *i2 = (const struct item *)i2_;
if (i1->nameid == i2->nameid)
return 0;
diff --git a/src/map/vending.c b/src/map/vending.c
index 6e74e6c3e..2346932ba 100644
--- a/src/map/vending.c
+++ b/src/map/vending.c
@@ -119,8 +119,8 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid,
z = 0; // zeny counter
w = 0; // weight counter
for( i = 0; i < count; i++ ) {
- short amount = *(uint16*)(data + 4*i + 0);
- short idx = *(uint16*)(data + 4*i + 2);
+ short amount = *(const uint16*)(data + 4*i + 0);
+ short idx = *(const uint16*)(data + 4*i + 2);
idx -= 2;
if( amount <= 0 )
@@ -185,8 +185,8 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid,
pc->getzeny(vsd, (int)z, LOG_TYPE_VENDING, sd);
for( i = 0; i < count; i++ ) {
- short amount = *(uint16*)(data + 4*i + 0);
- short idx = *(uint16*)(data + 4*i + 2);
+ short amount = *(const uint16*)(data + 4*i + 0);
+ short idx = *(const uint16*)(data + 4*i + 2);
idx -= 2;
// vending item
@@ -266,9 +266,9 @@ void vending_openvending(struct map_session_data* sd, const char* message, const
// filter out invalid items
i = 0;
for( j = 0; j < count; j++ ) {
- short index = *(uint16*)(data + 8*j + 0);
- short amount = *(uint16*)(data + 8*j + 2);
- unsigned int value = *(uint32*)(data + 8*j + 4);
+ short index = *(const uint16*)(data + 8*j + 0);
+ short amount = *(const uint16*)(data + 8*j + 2);
+ unsigned int value = *(const uint32*)(data + 8*j + 4);
index -= 2; // offset adjustment (client says that the first cart position is 2)