Skip to content

Commit

Permalink
Some more pointer casts and enum fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lemongrass3110 committed Oct 2, 2015
1 parent a760e01 commit a597e7b
Show file tree
Hide file tree
Showing 32 changed files with 119 additions and 118 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -12,6 +12,7 @@ Thumbs.db
# /
/*_fifo
/*.exe
/*.exe.*
/*.ilk
/*.log
/*.ncb
Expand Down
6 changes: 3 additions & 3 deletions src/char/char.c
Expand Up @@ -282,7 +282,7 @@ int char_mmo_char_tosql(uint32 char_id, struct mmo_charstatus* p){

if (char_id!=p->char_id) return 0;

cp = idb_ensure(char_db_, char_id, char_create_charstatus);
cp = (struct mmo_charstatus *)idb_ensure(char_db_, char_id, char_create_charstatus);

StringBuf_Init(&buf);
memset(save_status, 0, sizeof(save_status));
Expand Down Expand Up @@ -1283,7 +1283,7 @@ int char_mmo_char_fromsql(uint32 char_id, struct mmo_charstatus* p, bool load_ev
SqlStmt_Free(stmt);
StringBuf_Destroy(&buf);

cp = idb_ensure(char_db_, char_id, char_create_charstatus);
cp = (struct mmo_charstatus *)idb_ensure(char_db_, char_id, char_create_charstatus);
memcpy(cp, p, sizeof(struct mmo_charstatus));
StringBuf_Destroy(&msg_buf);
return 1;
Expand Down Expand Up @@ -2121,7 +2121,7 @@ int char_chardb_waiting_disconnect(int tid, unsigned int tick, int id, intptr_t
*/
static int char_online_data_cleanup_sub(DBKey key, DBData *data, va_list ap)
{
struct online_char_data *character= db_data2ptr(data);
struct online_char_data *character= (struct online_char_data *)db_data2ptr(data);
if (character->fd != -1)
return 0; //Character still connected
if (character->server == -2) //Unknown server.. set them offline
Expand Down
2 changes: 1 addition & 1 deletion src/char/char_logif.c
Expand Up @@ -82,7 +82,7 @@ void chlogif_pincode_start(int fd, struct char_session_data* sd){
* @see DBApply
*/
static int chlogif_send_acc_tologin_sub(DBKey key, DBData *data, va_list ap) {
struct online_char_data* character = db_data2ptr(data);
struct online_char_data* character = (struct online_char_data*)db_data2ptr(data);
int* i = va_arg(ap, int*);
if(character->server > -1) {
WFIFOL(login_fd,8+(*i)*4) = character->account_id;
Expand Down
4 changes: 2 additions & 2 deletions src/char/char_mapif.c
Expand Up @@ -361,7 +361,7 @@ int chmapif_parse_regmapuser(int fd, int id){
for(i = 0; i < map_server[id].users; i++) {
int aid = RFIFOL(fd,6+i*8);
int cid = RFIFOL(fd,6+i*8+4);
struct online_char_data* character = idb_ensure(online_char_db, aid, char_create_online_data);
struct online_char_data* character = (struct online_char_data*)idb_ensure(online_char_db, aid, char_create_online_data);
if( character->server > -1 && character->server != id )
{
ShowNotice("Set map user: Character (%d:%d) marked on map server %d, but map server %d claims to have (%d:%d) online!\n",
Expand Down Expand Up @@ -638,7 +638,7 @@ int chmapif_parse_reqchangemapserv(int fd){
node->changing_mapservers = 1;
idb_put(auth_db, aid, node);

data = idb_ensure(online_char_db, aid, char_create_online_data);
data = (struct online_char_data*)idb_ensure(online_char_db, aid, char_create_online_data);
data->char_id = char_data->char_id;
data->server = map_id; //Update server where char is.

Expand Down
2 changes: 1 addition & 1 deletion src/char/int_auction.c
Expand Up @@ -30,7 +30,7 @@ static int auction_count(int char_id, bool buy)
struct auction_data *auction;
DBIterator *iter = db_iterator(auction_db_);

for( auction = dbi_first(iter); dbi_exists(iter); auction = dbi_next(iter) )
for( auction = (struct auction_data *)dbi_first(iter); dbi_exists(iter); auction = (struct auction_data *)dbi_next(iter) )
{
if( (buy && auction->buyer_id == char_id) || (!buy && auction->seller_id == char_id) )
i++;
Expand Down
8 changes: 4 additions & 4 deletions src/char/int_guild.c
Expand Up @@ -54,7 +54,7 @@ static int guild_save_timer(int tid, unsigned int tick, int id, intptr_t data)
if( last_id == 0 ) //Save the first guild in the list.
state = 1;

for( g = db_data2ptr(iter->first(iter, &key)); dbi_exists(iter); g = db_data2ptr(iter->next(iter, &key)) )
for( g = (struct guild*)db_data2ptr(iter->first(iter, &key)); dbi_exists(iter); g = (struct guild*)db_data2ptr(iter->next(iter, &key)) )
{
if( state == 0 && g->guild_id == last_id )
state++; //Save next guild in the list.
Expand Down Expand Up @@ -547,7 +547,7 @@ static struct guild_castle* inter_guildcastle_fromsql(int castle_id)
char *data;
int i;
StringBuf buf;
struct guild_castle *gc = idb_get(castle_db, castle_id);
struct guild_castle *gc = (struct guild_castle *)idb_get(castle_db, castle_id);

if (gc != NULL)
return gc;
Expand Down Expand Up @@ -737,7 +737,7 @@ int inter_guild_sql_init(void)
*/
static int guild_db_final(DBKey key, DBData *data, va_list ap)
{
struct guild *g = db_data2ptr(data);
struct guild *g = (struct guild*)db_data2ptr(data);
if (g->save_flag&GS_MASK) {
inter_guild_tosql(g, g->save_flag&GS_MASK);
return 1;
Expand Down Expand Up @@ -1771,7 +1771,7 @@ int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value)
case 1:
if (charserv_config.log_inter && gc->guild_id != value) {
int gid = (value) ? value : gc->guild_id;
struct guild *g = idb_get(guild_db_, gid);
struct guild *g = (struct guild*)idb_get(guild_db_, gid);
inter_log("guild %s (id=%d) %s castle id=%d\n",
(g) ? g->name : "??", gid, (value) ? "occupy" : "abandon", castle_id);
}
Expand Down
2 changes: 1 addition & 1 deletion src/char/int_party.c
Expand Up @@ -750,7 +750,7 @@ int mapif_parse_PartyShareLevel(int fd,unsigned int share_lvl)

party_share_level = share_lvl;

for(p = dbi_first(iter); dbi_exists(iter); p = dbi_next(iter)) { //Update online parties
for(p = (struct party_data *)dbi_first(iter); dbi_exists(iter); p = (struct party_data *)dbi_next(iter)) { //Update online parties
if(p->party.count > 1)
int_party_calc_state(p);
}
Expand Down
2 changes: 1 addition & 1 deletion src/char/inter.c
Expand Up @@ -944,7 +944,7 @@ int mapif_disconnectplayer(int fd, uint32 account_id, uint32 char_id, int reason
int check_ttl_wisdata_sub(DBKey key, DBData *data, va_list ap)
{
unsigned long tick;
struct WisData *wd = db_data2ptr(data);
struct WisData *wd = (struct WisData *)db_data2ptr(data);
tick = va_arg(ap, unsigned long);

if (DIFF_TICK(tick, wd->tick) > WISDATA_TTL && wis_delnum < WISDELLIST_MAX)
Expand Down
6 changes: 3 additions & 3 deletions src/login/login.c
Expand Up @@ -92,7 +92,7 @@ DBData login_create_online_user(DBKey key, va_list args) {
*/
struct online_login_data* login_add_online_user(int char_server, uint32 account_id){
struct online_login_data* p;
p = idb_ensure(online_db, account_id, login_create_online_user);
p = (struct online_login_data*)idb_ensure(online_db, account_id, login_create_online_user);
p->char_server = char_server;
if( p->waiting_disconnect != INVALID_TIMER ) {
delete_timer(p->waiting_disconnect, login_waiting_disconnect_timer);
Expand Down Expand Up @@ -148,7 +148,7 @@ int login_waiting_disconnect_timer(int tid, unsigned int tick, int id, intptr_t
* @see DBApply
*/
int login_online_db_setoffline(DBKey key, DBData *data, va_list ap) {
struct online_login_data* p = db_data2ptr(data);
struct online_login_data* p = (struct online_login_data*)db_data2ptr(data);
int server = va_arg(ap, int);
if( server == -1 ) {
p->char_server = -1;
Expand All @@ -171,7 +171,7 @@ int login_online_db_setoffline(DBKey key, DBData *data, va_list ap) {
* @see DBApply
*/
static int login_online_data_cleanup_sub(DBKey key, DBData *data, va_list ap) {
struct online_login_data *character= db_data2ptr(data);
struct online_login_data *character= (struct online_login_data*)db_data2ptr(data);
if (character->char_server == -2) //Unknown server.. set them offline
login_remove_online_user(character->account_id);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/login/loginchrif.c
Expand Up @@ -535,7 +535,7 @@ int logchrif_parse_updonlinedb(int fd, int id){
users = RFIFOW(fd,4);
for (i = 0; i < users; i++) {
int aid = RFIFOL(fd,6+i*4);
struct online_login_data *p = idb_ensure(online_db, aid, login_create_online_user);
struct online_login_data *p = (struct online_login_data*)idb_ensure(online_db, aid, login_create_online_user);
p->char_server = id;
if (p->waiting_disconnect != INVALID_TIMER){
delete_timer(p->waiting_disconnect, login_waiting_disconnect_timer);
Expand Down
16 changes: 8 additions & 8 deletions src/map/atcommand.c
Expand Up @@ -1550,7 +1550,7 @@ ACMD_FUNC(help)
StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
command_info = get_atcommandinfo_byname(command_name);
iter = db_iterator(atcommand_alias_db);
for (alias_info = dbi_first(iter); dbi_exists(iter); alias_info = dbi_next(iter)) {
for (alias_info = (AliasInfo *)dbi_first(iter); dbi_exists(iter); alias_info = (AliasInfo *)dbi_next(iter)) {
if (alias_info->command == command_info) {
StringBuf_Printf(&buf, " %s", alias_info->alias);
has_aliases = true;
Expand Down Expand Up @@ -8828,7 +8828,7 @@ static void atcommand_commands_sub(struct map_session_data* sd, const int fd, At

clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"

for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
unsigned int slen = 0;

switch( type ) {
Expand Down Expand Up @@ -10084,7 +10084,7 @@ static void atcommand_get_suggestions(struct map_session_data* sd, const char *n
alias_iter = db_iterator(atcommand_alias_db);

// Build the matches
for (command_info = dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = dbi_next(atcommand_iter)) {
for (command_info = (AtCommandInfo*)dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = (AtCommandInfo*)dbi_next(atcommand_iter)) {
match = strstr(command_info->command, name);
can_use = pc_can_use_command(sd, command_info->command, type);
if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
Expand All @@ -10097,7 +10097,7 @@ static void atcommand_get_suggestions(struct map_session_data* sd, const char *n
}
}

for (alias_info = dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = dbi_next(alias_iter)) {
for (alias_info = (AliasInfo *)dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = (AliasInfo *)dbi_next(alias_iter)) {
match = strstr(alias_info->alias, name);
can_use = pc_can_use_command(sd, alias_info->command->command, type);
if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
Expand Down Expand Up @@ -10437,9 +10437,9 @@ void atcommand_db_load_groups(int* group_ids) {
AtCommandInfo* cmd;
int i;

for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
cmd->at_groups = aMalloc( pc_group_max * sizeof(char) );
cmd->char_groups = aMalloc( pc_group_max * sizeof(char) );
for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
cmd->at_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
cmd->char_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
for(i = 0; i < pc_group_max; i++) {
if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
cmd->at_groups[i] = 1;
Expand All @@ -10462,7 +10462,7 @@ void atcommand_db_clear(void) {
DBIterator *iter = db_iterator(atcommand_db);
AtCommandInfo* cmd;

for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
aFree(cmd->at_groups);
aFree(cmd->char_groups);
}
Expand Down
2 changes: 1 addition & 1 deletion src/map/battleground.c
Expand Up @@ -238,7 +238,7 @@ int bg_send_message(struct map_session_data *sd, const char *mes, int len)
*/
int bg_send_xy_timer_sub(DBKey key, DBData *data, va_list ap)
{
struct battleground_data *bg = db_data2ptr(data);
struct battleground_data *bg = (struct battleground_data *)db_data2ptr(data);
struct map_session_data *sd;
int i;

Expand Down
6 changes: 3 additions & 3 deletions src/map/buyingstore.c
Expand Up @@ -586,7 +586,7 @@ void buyingstore_reopen( struct map_session_data* sd ){
nullpo_retv(sd);

// Ready to open buyingstore for this char
if ((at = uidb_get(buyingstore_autotrader_db, sd->status.char_id)) && at->count && at->entries) {
if ((at = (struct s_autotrader *)uidb_get(buyingstore_autotrader_db, sd->status.char_id)) && at->count && at->entries) {
uint8 *data, *p;
uint16 j, count;

Expand Down Expand Up @@ -704,7 +704,7 @@ void do_init_buyingstore_autotrade( void ) {

// Init items for each autotraders
iter = db_iterator(buyingstore_autotrader_db);
for (at = dbi_first(iter); dbi_exists(iter); at = dbi_next(iter)) {
for (at = (struct s_autotrader *)dbi_first(iter); dbi_exists(iter); at = (struct s_autotrader *)dbi_next(iter)) {
uint16 j = 0;

if (SQL_ERROR == Sql_Query(mmysql_handle,
Expand Down Expand Up @@ -779,7 +779,7 @@ static void buyingstore_autotrader_remove(struct s_autotrader *at, bool remove)
* @author [Cydh]
*/
static int buyingstore_autotrader_free(DBKey key, DBData *data, va_list ap) {
struct s_autotrader *at = db_data2ptr(data);
struct s_autotrader *at = (struct s_autotrader *)db_data2ptr(data);
if (at)
buyingstore_autotrader_remove(at, false);
return 0;
Expand Down
8 changes: 4 additions & 4 deletions src/map/channel.c
Expand Up @@ -79,7 +79,7 @@ int channel_delete(struct Channel *channel) {
if( db_size(channel->users)) {
struct map_session_data *sd;
DBIterator *iter = db_iterator(channel->users);
for( sd = dbi_first(iter); dbi_exists(iter); sd = dbi_next(iter) ) { //for all users
for( sd = (struct map_session_data *)dbi_first(iter); dbi_exists(iter); sd = (struct map_session_data *)dbi_next(iter) ) { //for all users
channel_clean(channel,sd,1); //make all quit
}
dbi_destroy(iter);
Expand Down Expand Up @@ -525,7 +525,7 @@ int channel_display_list(struct map_session_data *sd, char *options){
}
}
iter = db_iterator(channel_db);
for(channel = dbi_first(iter); dbi_exists(iter); channel = dbi_next(iter)) {
for(channel = (struct Channel *)dbi_first(iter); dbi_exists(iter); channel = (struct Channel *)dbi_next(iter)) {
if( has_perm || channel->type == CHAN_TYPE_PUBLIC ) {
sprintf(output, msg_txt(sd,1409), channel->name, db_size(channel->users));// - #%s (%d users)
clif_displaymessage(sd->fd, output);
Expand Down Expand Up @@ -890,7 +890,7 @@ int channel_pcban(struct map_session_data *sd, char *chname, char *pname, int fl
struct chan_banentry *cbe;
sprintf(output, msg_txt(sd,1443), channel->name);// ---- '#%s' Ban List:
clif_displaymessage(sd->fd, output);
for( cbe = dbi_first(iter); dbi_exists(iter); cbe = dbi_next(iter) ) { //for all users
for( cbe = (struct chan_banentry *)dbi_first(iter); dbi_exists(iter); cbe = (struct chan_banentry *)dbi_next(iter) ) { //for all users
sprintf(output, "%d: %s",cbe->char_id,cbe->char_name);
clif_displaymessage(sd->fd, output);
}
Expand Down Expand Up @@ -1159,7 +1159,7 @@ void do_final_channel(void) {

//delete all in remaining chan db
iter = db_iterator(channel_db);
for( channel = dbi_first(iter); dbi_exists(iter); channel = dbi_next(iter) ) {
for( channel = (struct Channel *)dbi_first(iter); dbi_exists(iter); channel = (struct Channel *)dbi_next(iter) ) {
channel_delete(channel);
}
dbi_destroy(iter);
Expand Down
6 changes: 3 additions & 3 deletions src/map/chrif.c
Expand Up @@ -511,7 +511,7 @@ int chrif_connectack(int fd) {
* @see DBApply
*/
static int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
struct auth_node *node = db_data2ptr(data);
struct auth_node *node = (struct auth_node *)db_data2ptr(data);

switch (node->state) {
case ST_LOGIN:
Expand Down Expand Up @@ -749,7 +749,7 @@ void chrif_authfail(int fd) {/* HELLO WORLD. ip in RFIFOL 15 is not being used (
* @see DBApply
*/
int auth_db_cleanup_sub(DBKey key, DBData *data, va_list ap) {
struct auth_node *node = db_data2ptr(data);
struct auth_node *node = (struct auth_node *)db_data2ptr(data);

if(DIFF_TICK(gettick(),node->node_created)>60000) {
const char* states[] = { "Login", "Logout", "Map change" };
Expand Down Expand Up @@ -1935,7 +1935,7 @@ int chrif_send_report(char* buf, int len) {
* @see DBApply
*/
int auth_db_final(DBKey key, DBData *data, va_list ap) {
struct auth_node *node = db_data2ptr(data);
struct auth_node *node = (struct auth_node *)db_data2ptr(data);

if (node->char_dat)
aFree(node->char_dat);
Expand Down
6 changes: 3 additions & 3 deletions src/map/clif.c
Expand Up @@ -5884,7 +5884,7 @@ void clif_channel_msg(struct Channel *channel, struct map_session_data *sd, char
safestrncpy((char*)WFIFOP(sd->fd,12), msg, msg_len);

iter = db_iterator(channel->users);
for( user = dbi_first(iter); dbi_exists(iter); user = dbi_next(iter) ) {
for( user = (struct map_session_data *)dbi_first(iter); dbi_exists(iter); user = (struct map_session_data *)dbi_next(iter) ) {
if( user->fd == sd->fd )
continue;
WFIFOHEAD(user->fd,msg_len + 12);
Expand Down Expand Up @@ -6108,7 +6108,7 @@ void clif_wis_message(int fd, const char* nick, const char* mes, int mes_len)
/// 3 = everyone ignored by target
void clif_wis_end(int fd, int result)
{
struct map_session_data *sd = (session_isValid(fd) ? session[fd]->session_data : NULL);
struct map_session_data *sd = (session_isValid(fd) ? (struct map_session_data *)session[fd]->session_data : NULL);

if (!sd)
return;
Expand Down Expand Up @@ -17203,7 +17203,7 @@ void clif_parse_SkillSelectMenu(int fd, struct map_session_data *sd) {
return;

if( pc_istrading(sd) ) {
clif_skill_fail(sd,sd->ud.skill_id,0,0);
clif_skill_fail(sd,sd->ud.skill_id,USESKILL_FAIL_LEVEL,0);
clif_menuskill_clear(sd);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/map/elemental.c
Expand Up @@ -191,12 +191,12 @@ int elemental_delete(struct elemental_data *ed, int reply) {
elemental_summon_stop(ed);

if( !sd )
return unit_free(&ed->bl, 0);
return unit_free(&ed->bl, CLR_OUTSIGHT);

sd->ed = NULL;
sd->status.ele_id = 0;

return unit_remove_map(&ed->bl, 0);
return unit_remove_map(&ed->bl, CLR_OUTSIGHT);
}

void elemental_summon_init(struct elemental_data *ed) {
Expand Down

0 comments on commit a597e7b

Please sign in to comment.