From 0aee4fd57f2f4135361f4182a08a98cf52ed9d10 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Wed, 15 May 2013 16:47:08 -0300 Subject: HPM Update Made SQL and strlib functions HPM-friendly, special thanks to Yommy for bringing the issue up. Added partial map.c support, for the all-handy map[] array, beware that soon the whole map.c renewal design will be commit and when that happens your usage of map.c functions in plugins might require some updates. Signed-off-by: shennetsind --- src/map/atcommand.c | 182 +++++++++++++++++++++++++-------------------------- src/map/chrif.c | 4 +- src/map/clif.c | 24 +++---- src/map/guild.c | 21 +++--- src/map/homunculus.c | 4 +- src/map/itemdb.c | 39 +++++------ src/map/log.c | 6 +- src/map/map.c | 79 +++++++++++++++------- src/map/map.h | 45 +++++++------ src/map/mapreg_sql.c | 20 +++--- src/map/mercenary.c | 4 +- src/map/mob.c | 26 ++++---- src/map/npc.c | 10 +-- src/map/pc.c | 8 +-- src/map/pc_groups.c | 4 +- src/map/script.c | 166 +++++++++++++++++++++++----------------------- src/map/skill.c | 32 ++++----- src/map/status.c | 10 +-- 18 files changed, 360 insertions(+), 324 deletions(-) (limited to 'src/map') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 6ffceac8e..428113c68 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -581,70 +581,70 @@ ACMD(who) display_type = 3; level = pc_get_group_level(sd); - StringBuf_Init(&buf); + StrBuf->Init(&buf); iter = mapit_getallusers(); - for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) { + for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) { if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || (pl_sd->sc.option & OPTION_INVISIBLE)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive || (map_id >= 0 && pl_sd->bl.m != map_id)) continue; switch (display_type) { case 2: { - StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s " + StrBuf->Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s " if (pc_get_group_id(pl_sd) > 0) // Player title, if exists - StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) " - StringBuf_Printf(&buf, msg_txt(347), pl_sd->status.base_level, pl_sd->status.job_level, + StrBuf->Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) " + StrBuf->Printf(&buf, msg_txt(347), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s" break; } case 3: { if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID)) - StringBuf_Printf(&buf, msg_txt(912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) " - StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s " + StrBuf->Printf(&buf, msg_txt(912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) " + StrBuf->Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s " if (pc_get_group_id(pl_sd) > 0) // Player title, if exists - StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) " - StringBuf_Printf(&buf, msg_txt(348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d" + StrBuf->Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) " + StrBuf->Printf(&buf, msg_txt(348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d" break; } default: { struct party_data *p = party_search(pl_sd->status.party_id); struct guild *g = pl_sd->guild; - StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s " + StrBuf->Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s " if (pc_get_group_id(pl_sd) > 0) // Player title, if exists - StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) " + StrBuf->Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) " if (p != NULL) - StringBuf_Printf(&buf, msg_txt(345), p->party.name); // " | Party: '%s'" + StrBuf->Printf(&buf, msg_txt(345), p->party.name); // " | Party: '%s'" if (g != NULL) - StringBuf_Printf(&buf, msg_txt(346), g->name); // " | Guild: '%s'" + StrBuf->Printf(&buf, msg_txt(346), g->name); // " | Guild: '%s'" break; } } - clif->message(fd, StringBuf_Value(&buf)); - StringBuf_Clear(&buf); + clif->message(fd, StrBuf->Value(&buf)); + StrBuf->Clear(&buf); count++; } } - mapit_free(iter); + mapit->free(iter); if (map_id < 0) { if (count == 0) - StringBuf_Printf(&buf, msg_txt(28)); // No player found. + StrBuf->Printf(&buf, msg_txt(28)); // No player found. else if (count == 1) - StringBuf_Printf(&buf, msg_txt(29)); // 1 player found. + StrBuf->Printf(&buf, msg_txt(29)); // 1 player found. else - StringBuf_Printf(&buf, msg_txt(30), count); // %d players found. + StrBuf->Printf(&buf, msg_txt(30), count); // %d players found. } else { if (count == 0) - StringBuf_Printf(&buf, msg_txt(54), map[map_id].name); // No player found in map '%s'. + StrBuf->Printf(&buf, msg_txt(54), map[map_id].name); // No player found in map '%s'. else if (count == 1) - StringBuf_Printf(&buf, msg_txt(55), map[map_id].name); // 1 player found in map '%s'. + StrBuf->Printf(&buf, msg_txt(55), map[map_id].name); // 1 player found in map '%s'. else - StringBuf_Printf(&buf, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'. + StrBuf->Printf(&buf, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'. } - clif->message(fd, StringBuf_Value(&buf)); - StringBuf_Destroy(&buf); + clif->message(fd, StrBuf->Value(&buf)); + StrBuf->Destroy(&buf); return true; } @@ -677,7 +677,7 @@ ACMD(whogm) level = pc_get_group_level(sd); iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { pl_level = pc_get_group_level(pl_sd); if (!pl_level) @@ -720,7 +720,7 @@ ACMD(whogm) clif->message(fd, atcmd_output); count++; } - mapit_free(iter); + mapit->free(iter); if (count == 0) clif->message(fd, msg_txt(150)); // No GM found. @@ -1427,20 +1427,20 @@ ACMD(help) { StringBuf buf; bool has_aliases = false; - StringBuf_Init(&buf); - StringBuf_AppendStr(&buf, msg_txt(990)); // Available aliases: + StrBuf->Init(&buf); + StrBuf->AppendStr(&buf, msg_txt(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)) { if (alias_info->command == command_info) { - StringBuf_Printf(&buf, " %s", alias_info->alias); + StrBuf->Printf(&buf, " %s", alias_info->alias); has_aliases = true; } } dbi_destroy(iter); if (has_aliases) - clif->message(fd, StringBuf_Value(&buf)); - StringBuf_Destroy(&buf); + clif->message(fd, StrBuf->Value(&buf)); + StrBuf->Destroy(&buf); } // Display help contents @@ -2936,7 +2936,7 @@ ACMD(doom) nullpo_retr(-1, sd); iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { @@ -2945,7 +2945,7 @@ ACMD(doom) clif->message(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement. } } - mapit_free(iter); + mapit->free(iter); clif->message(fd, msg_txt(62)); // Judgement was made. @@ -2963,7 +2963,7 @@ ACMD(doommap) nullpo_retr(-1, sd); iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { @@ -2972,7 +2972,7 @@ ACMD(doommap) clif->message(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement. } } - mapit_free(iter); + mapit->free(iter); clif->message(fd, msg_txt(62)); // Judgement was made. @@ -3001,10 +3001,10 @@ ACMD(raise) nullpo_retr(-1, sd); iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) if( pc_isdead(pl_sd) ) atcommand_raise_sub(pl_sd); - mapit_free(iter); + mapit->free(iter); clif->message(fd, msg_txt(64)); // Mercy has been granted. @@ -3022,10 +3022,10 @@ ACMD(raisemap) nullpo_retr(-1, sd); iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) ) atcommand_raise_sub(pl_sd); - mapit_free(iter); + mapit->free(iter); clif->message(fd, msg_txt(64)); // Mercy has been granted. @@ -3074,14 +3074,14 @@ ACMD(kickall) nullpo_retr(-1, sd); iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level if (sd->status.account_id != pl_sd->status.account_id) clif->GM_kick(NULL, pl_sd); } } - mapit_free(iter); + mapit->free(iter); clif->message(fd, msg_txt(195)); // All players have been kicked! @@ -3431,7 +3431,7 @@ ACMD(recallall) count = 0; iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { @@ -3448,7 +3448,7 @@ ACMD(recallall) } } } - mapit_free(iter); + mapit->free(iter); clif->message(fd, msg_txt(92)); // All characters recalled! if (count) { @@ -3494,7 +3494,7 @@ ACMD(guildrecall) count = 0; iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id) { @@ -3506,7 +3506,7 @@ ACMD(guildrecall) pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN); } } - mapit_free(iter); + mapit->free(iter); sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position. clif->message(fd, atcmd_output); @@ -3553,7 +3553,7 @@ ACMD(partyrecall) count = 0; iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id) { @@ -3565,7 +3565,7 @@ ACMD(partyrecall) pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN); } } - mapit_free(iter); + mapit->free(iter); sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position. clif->message(fd, atcmd_output); @@ -3792,7 +3792,7 @@ ACMD(mapinfo) { // count chats (for initial message) chat_num = 0; iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) { + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { if( pl_sd->mapindex == m_index ) { if( pl_sd->state.vending ) vend_num++; @@ -3800,7 +3800,7 @@ ACMD(mapinfo) { chat_num++; } } - mapit_free(iter); + mapit->free(iter); sprintf(atcmd_output, msg_txt(1040), mapname, map[m_id].zone->name, map[m_id].users, map[m_id].npc_num, chat_num, vend_num); // Map: %s (Zone:%s) | Players: %d | NPCs: %d | Chats: %d | Vendings: %d clif->message(fd, atcmd_output); @@ -3935,7 +3935,7 @@ ACMD(mapinfo) { case 1: clif->message(fd, msg_txt(1098)); // ----- Players in Map ----- iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { if (pl_sd->mapindex == m_index) { sprintf(atcmd_output, msg_txt(1099), // Player '%s' (session #%d) | Location: %d,%d @@ -3943,7 +3943,7 @@ ACMD(mapinfo) { clif->message(fd, atcmd_output); } } - mapit_free(iter); + mapit->free(iter); break; case 2: clif->message(fd, msg_txt(1100)); // ----- NPCs in Map ----- @@ -3974,7 +3974,7 @@ ACMD(mapinfo) { case 3: clif->message(fd, msg_txt(1113)); // ----- Chats in Map ----- iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && @@ -3988,7 +3988,7 @@ ACMD(mapinfo) { clif->message(fd, atcmd_output); } } - mapit_free(iter); + mapit->free(iter); break; default: // normally impossible to arrive here clif->message(fd, msg_txt(1118)); // Please enter at least one valid list number (usage: @mapinfo <0-3> ). @@ -4778,9 +4778,9 @@ ACMD(disguiseall) } iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) pc_disguise(pl_sd, mob_id); - mapit_free(iter); + mapit->free(iter); clif->message(fd, msg_txt(122)); // Disguise applied. return true; @@ -4860,10 +4860,10 @@ ACMD(undisguiseall) { nullpo_retr(-1, sd); iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) if( pl_sd->disguise != -1 ) pc_disguise(pl_sd, -1); - mapit_free(iter); + mapit->free(iter); clif->message(fd, msg_txt(124)); // Undisguise applied. @@ -6088,7 +6088,7 @@ ACMD(mobsearch) it = mapit_geteachmob(); for(;;) { - TBL_MOB* md = (TBL_MOB*)mapit_next(it); + TBL_MOB* md = (TBL_MOB*)mapit->next(it); if( md == NULL ) break;// no more mobs @@ -6104,7 +6104,7 @@ ACMD(mobsearch) snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name); clif->message(fd, atcmd_output); } - mapit_free(it); + mapit->free(it); return true; } @@ -6270,7 +6270,7 @@ ACMD(users) iter = mapit_getallusers(); for(;;) { - struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter); + struct map_session_data* sd2 = (struct map_session_data*)mapit->next(iter); if( sd2 == NULL ) break;// no more users @@ -6280,7 +6280,7 @@ ACMD(users) if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex]; if( users_all < INT_MAX ) ++users_all; } - mapit_free(iter); + mapit->free(iter); // display results for each map for( i = 0; i < MAX_MAPINDEX; ++i ) @@ -6564,9 +6564,9 @@ ACMD(refreshall) nullpo_retr(-1, sd); iter = mapit_getallusers(); - for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter)) + for (iter_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); iter_sd = (TBL_PC*)mapit->next(iter)) clif->refresh(iter_sd); - mapit_free(iter); + mapit->free(iter); return true; } @@ -6808,7 +6808,7 @@ ACMD(showmobs) it = mapit_geteachmob(); for(;;) { - TBL_MOB* md = (TBL_MOB*)mapit_next(it); + TBL_MOB* md = (TBL_MOB*)mapit->next(it); if( md == NULL ) break;// no more mobs @@ -6824,7 +6824,7 @@ ACMD(showmobs) ++number; clif->viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF); } - mapit_free(it); + mapit->free(it); return true; } @@ -7444,7 +7444,7 @@ ACMD(sizeall) size = cap_value(size,0,2); iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) { + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { if( pl_sd->state.size != size ) { if( pl_sd->state.size ) { pl_sd->state.size = SZ_SMALL; @@ -7458,7 +7458,7 @@ ACMD(sizeall) clif->specialeffect(&pl_sd->bl,422,AREA); } } - mapit_free(iter); + mapit->free(iter); clif->message(fd, msg_txt(1303)); // Size change applied. return true; @@ -8124,7 +8124,7 @@ ACMD(itemlist) else return 1; - StringBuf_Init(&buf); + StrBuf->Init(&buf); count = 0; // total slots occupied counter = 0; // total items found @@ -8141,15 +8141,15 @@ ACMD(itemlist) if( count == 1 ) { - StringBuf_Printf(&buf, msg_txt(1332), location, sd->status.name); // ------ %s items list of '%s' ------ - clif->message(fd, StringBuf_Value(&buf)); - StringBuf_Clear(&buf); + StrBuf->Printf(&buf, msg_txt(1332), location, sd->status.name); // ------ %s items list of '%s' ------ + clif->message(fd, StrBuf->Value(&buf)); + StrBuf->Clear(&buf); } if( it->refine ) - StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid); + StrBuf->Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid); else - StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid); + StrBuf->Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid); if( it->equip ) { @@ -8185,28 +8185,28 @@ ACMD(itemlist) strcat(equipstr, msg_txt(1347)); // lower/mid/top head, // remove final ', ' equipstr[strlen(equipstr) - 2] = '\0'; - StringBuf_AppendStr(&buf, equipstr); + StrBuf->AppendStr(&buf, equipstr); } - clif->message(fd, StringBuf_Value(&buf)); - StringBuf_Clear(&buf); + clif->message(fd, StrBuf->Value(&buf)); + StrBuf->Clear(&buf); if( it->card[0] == CARD0_PET ) {// pet egg if (it->card[3]) - StringBuf_Printf(&buf, msg_txt(1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named) + StrBuf->Printf(&buf, msg_txt(1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named) else - StringBuf_Printf(&buf, msg_txt(1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed) + StrBuf->Printf(&buf, msg_txt(1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed) } else if(it->card[0] == CARD0_FORGE) {// forged item - StringBuf_Printf(&buf, msg_txt(1350), (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f); // -> (crafted item, creator id: %u, star crumbs %d, element %d) + StrBuf->Printf(&buf, msg_txt(1350), (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f); // -> (crafted item, creator id: %u, star crumbs %d, element %d) } else if(it->card[0] == CARD0_CREATE) {// created item - StringBuf_Printf(&buf, msg_txt(1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u) + StrBuf->Printf(&buf, msg_txt(1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u) } else {// normal item @@ -8222,32 +8222,32 @@ ACMD(itemlist) counter2++; if( counter2 == 1 ) - StringBuf_AppendStr(&buf, msg_txt(1352)); // -> (card(s): + StrBuf->AppendStr(&buf, msg_txt(1352)); // -> (card(s): if( counter2 != 1 ) - StringBuf_AppendStr(&buf, ", "); + StrBuf->AppendStr(&buf, ", "); - StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid); + StrBuf->Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid); } if( counter2 > 0 ) - StringBuf_AppendStr(&buf, ")"); + StrBuf->AppendStr(&buf, ")"); } - if( StringBuf_Length(&buf) > 0 ) - clif->message(fd, StringBuf_Value(&buf)); + if( StrBuf->Length(&buf) > 0 ) + clif->message(fd, StrBuf->Value(&buf)); - StringBuf_Clear(&buf); + StrBuf->Clear(&buf); } if( count == 0 ) - StringBuf_Printf(&buf, msg_txt(1353), location); // No item found in this player's %s. + StrBuf->Printf(&buf, msg_txt(1353), location); // No item found in this player's %s. else - StringBuf_Printf(&buf, msg_txt(1354), counter, count, location); // %d item(s) found in %d %s slots. + StrBuf->Printf(&buf, msg_txt(1354), counter, count, location); // %d item(s) found in %d %s slots. - clif->message(fd, StringBuf_Value(&buf)); + clif->message(fd, StrBuf->Value(&buf)); - StringBuf_Destroy(&buf); + StrBuf->Destroy(&buf); return true; } diff --git a/src/map/chrif.c b/src/map/chrif.c index eed7ba2a6..c5ff16713 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -1509,13 +1509,13 @@ int send_users_tochar(void) { iter = mapit_getallusers(); - for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) ) { + for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) { WFIFOL(char_fd,6+8*i) = sd->status.account_id; WFIFOL(char_fd,6+8*i+4) = sd->status.char_id; i++; } - mapit_free(iter); + mapit->free(iter); WFIFOW(char_fd,2) = 6 + 8*users; WFIFOW(char_fd,4) = users; diff --git a/src/map/clif.c b/src/map/clif.c index 4edb1541d..06f180a35 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -336,24 +336,24 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target case ALL_CLIENT: //All player clients. iter = mapit_getallusers(); - while( (tsd = (TBL_PC*)mapit_next(iter)) != NULL ) { + while( (tsd = (TBL_PC*)mapit->next(iter)) != NULL ) { WFIFOHEAD(tsd->fd, len); memcpy(WFIFOP(tsd->fd,0), buf, len); WFIFOSET(tsd->fd,len); } - mapit_free(iter); + mapit->free(iter); break; case ALL_SAMEMAP: //All players on the same map iter = mapit_getallusers(); - while( (tsd = (TBL_PC*)mapit_next(iter)) != NULL ) { + while( (tsd = (TBL_PC*)mapit->next(iter)) != NULL ) { if( bl->m == tsd->bl.m ) { WFIFOHEAD(tsd->fd, len); memcpy(WFIFOP(tsd->fd,0), buf, len); WFIFOSET(tsd->fd,len); } } - mapit_free(iter); + mapit->free(iter); break; case AREA: @@ -431,14 +431,14 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target break; iter = mapit_getallusers(); - while( (tsd = (TBL_PC*)mapit_next(iter)) != NULL ) { + while( (tsd = (TBL_PC*)mapit->next(iter)) != NULL ) { if( tsd->partyspy == p->party.party_id ) { WFIFOHEAD(tsd->fd, len); memcpy(WFIFOP(tsd->fd,0), buf, len); WFIFOSET(tsd->fd,len); } } - mapit_free(iter); + mapit->free(iter); } break; @@ -447,7 +447,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target if (!sd || !sd->duel_group) break; //Invalid usage. iter = mapit_getallusers(); - while( (tsd = (TBL_PC*)mapit_next(iter)) != NULL ) { + while( (tsd = (TBL_PC*)mapit->next(iter)) != NULL ) { if( type == DUEL_WOS && bl->id == tsd->bl.id ) continue; if( sd->duel_group == tsd->duel_group ) { @@ -456,7 +456,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target WFIFOSET(tsd->fd,len); } } - mapit_free(iter); + mapit->free(iter); break; case SELF: @@ -508,14 +508,14 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target break; iter = mapit_getallusers(); - while( (tsd = (TBL_PC*)mapit_next(iter)) != NULL ) { + while( (tsd = (TBL_PC*)mapit->next(iter)) != NULL ) { if( tsd->guildspy == g->guild_id ) { WFIFOHEAD(tsd->fd, len); memcpy(WFIFOP(tsd->fd,0), buf, len); WFIFOSET(tsd->fd,len); } } - mapit_free(iter); + mapit->free(iter); } break; @@ -1311,12 +1311,12 @@ void clif_weather(int16 m) struct map_session_data *sd=NULL; iter = mapit_getallusers(); - for( sd = (struct map_session_data*)mapit_first(iter); mapit_exists(iter); sd = (struct map_session_data*)mapit_next(iter) ) + 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); } - mapit_free(iter); + mapit->free(iter); } /** * Main function to spawn a unit on the client (player/mob/pet/etc) diff --git a/src/map/guild.c b/src/map/guild.c index 5e8a5897a..a028cb201 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -1,5 +1,6 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams #include "../common/cbasetypes.h" #include "../common/timer.h" @@ -457,7 +458,7 @@ int guild_check_member(struct guild *g) nullpo_ret(g); iter = mapit_getallusers(); - for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) ) + for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) { if( sd->status.guild_id != g->guild_id ) continue; @@ -469,7 +470,7 @@ int guild_check_member(struct guild *g) ShowWarning("guild: check_member %d[%s] is not member\n",sd->status.account_id,sd->status.name); } } - mapit_free(iter); + mapit->free(iter); return 0; } @@ -481,11 +482,11 @@ int guild_recv_noinfo(int guild_id) struct s_mapiterator* iter; iter = mapit_getallusers(); - for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) ) { + for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) { if( sd->status.guild_id == guild_id ) sd->status.guild_id = 0; // erase guild } - mapit_free(iter); + mapit->free(iter); return 0; } @@ -523,7 +524,7 @@ int guild_recv_info(struct guild *sg) { tg[i] = guild_search(sg->alliance[i].guild_id); } - for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) ) { + for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) { if( sd->status.guild_id ) { if( sd->status.guild_id == sg->guild_id ) { clif->chsys_join(channel,sd); @@ -543,7 +544,7 @@ int guild_recv_info(struct guild *sg) { } } - mapit_free(iter); + mapit->free(iter); } @@ -2197,10 +2198,10 @@ void do_init_guild(void) { guild_flags_count = 0; - sv_readdb(db_path, "castle_db.txt", ',', 4, 5, -1, &guild_read_castledb); + sv->readdb(db_path, "castle_db.txt", ',', 4, 5, -1, &guild_read_castledb); memset(guild_skill_tree,0,sizeof(guild_skill_tree)); - sv_readdb(db_path, "guild_skill_tree.txt", ',', 2+MAX_GUILD_SKILL_REQUIRE*2, 2+MAX_GUILD_SKILL_REQUIRE*2, -1, &guild_read_guildskill_tree_db); //guild skill tree [Komurka] + sv->readdb(db_path, "guild_skill_tree.txt", ',', 2+MAX_GUILD_SKILL_REQUIRE*2, 2+MAX_GUILD_SKILL_REQUIRE*2, -1, &guild_read_guildskill_tree_db); //guild skill tree [Komurka] add_timer_func_list(guild_payexp_timer,"guild_payexp_timer"); add_timer_func_list(guild_send_xy_timer, "guild_send_xy_timer"); diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 026b9a86c..e306e7f60 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -1134,7 +1134,7 @@ void homunculus_read_db(void) { } } - sv_readdb(db_path, filename[i], ',', 50, 50, MAX_HOMUNCULUS_CLASS, homun->read_db_sub); + sv->readdb(db_path, filename[i], ',', 50, 50, MAX_HOMUNCULUS_CLASS, homun->read_db_sub); } } @@ -1180,7 +1180,7 @@ bool homunculus_read_skill_db_sub(char* split[], int columns, int current) { void homunculus_skill_db_read(void) { memset(homun->skill_tree,0,sizeof(homun->skill_tree)); - sv_readdb(db_path, "homun_skill_tree.txt", ',', 13, 15, -1, homun->read_skill_db_sub); + sv->readdb(db_path, "homun_skill_tree.txt", ',', 13, 15, -1, homun->read_skill_db_sub); } diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 0b4419e0c..590a0cf57 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1,5 +1,6 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams #include "../common/nullpo.h" #include "../common/malloc.h" @@ -1236,19 +1237,19 @@ static int itemdb_read_sqldb(void) { uint32 lines = 0, count = 0; // retrieve all rows from the item database - if( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT * FROM `%s`", item_db_name[fi]) ) { + if( SQL_ERROR == SQL->Query(mmysql_handle, "SELECT * FROM `%s`", item_db_name[fi]) ) { Sql_ShowDebug(mmysql_handle); continue; } // process rows one by one - while( SQL_SUCCESS == Sql_NextRow(mmysql_handle) ) {// wrap the result into a TXT-compatible format + while( SQL_SUCCESS == SQL->NextRow(mmysql_handle) ) {// wrap the result into a TXT-compatible format char* str[22]; char* dummy = ""; int i; ++lines; for( i = 0; i < 22; ++i ) { - Sql_GetData(mmysql_handle, i, &str[i], NULL); + SQL->GetData(mmysql_handle, i, &str[i], NULL); if( str[i] == NULL ) str[i] = dummy; // get rid of NULL columns } @@ -1259,7 +1260,7 @@ static int itemdb_read_sqldb(void) { } // free the query result - Sql_FreeResult(mmysql_handle); + SQL->FreeResult(mmysql_handle); ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, item_db_name[fi]); } @@ -1295,19 +1296,19 @@ uint64 itemdb_unique_id(int8 flag, int64 value) { int itemdb_uid_load(){ char * uid; - if (SQL_ERROR == Sql_Query(mmysql_handle, "SELECT `value` FROM `interreg` WHERE `varname`='unique_id'")) + if (SQL_ERROR == SQL->Query(mmysql_handle, "SELECT `value` FROM `interreg` WHERE `varname`='unique_id'")) Sql_ShowDebug(mmysql_handle); - if( SQL_SUCCESS != Sql_NextRow(mmysql_handle) ) + if( SQL_SUCCESS != SQL->NextRow(mmysql_handle) ) { ShowError("itemdb_uid_load: Unable to fetch unique_id data\n"); - Sql_FreeResult(mmysql_handle); + SQL->FreeResult(mmysql_handle); return -1; } - Sql_GetData(mmysql_handle, 0, &uid, NULL); + SQL->GetData(mmysql_handle, 0, &uid, NULL); itemdb_unique_id(1, (uint64)strtoull(uid, NULL, 10)); - Sql_FreeResult(mmysql_handle); + SQL->FreeResult(mmysql_handle); return 0; } @@ -1324,12 +1325,12 @@ static void itemdb_read(void) { itemdb_read_combos(); itemdb_read_itemgroup(); - sv_readdb(db_path, "item_avail.txt", ',', 2, 2, -1, &itemdb_read_itemavail); - sv_readdb(db_path, DBPATH"item_trade.txt", ',', 3, 3, -1, &itemdb_read_itemtrade); - sv_readdb(db_path, "item_delay.txt", ',', 2, 2, -1, &itemdb_read_itemdelay); - sv_readdb(db_path, "item_stack.txt", ',', 3, 3, -1, &itemdb_read_stack); - sv_readdb(db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, &itemdb_read_buyingstore); - sv_readdb(db_path, "item_nouse.txt", ',', 3, 3, -1, &itemdb_read_nouse); + sv->readdb(db_path, "item_avail.txt", ',', 2, 2, -1, &itemdb_read_itemavail); + sv->readdb(db_path, DBPATH"item_trade.txt", ',', 3, 3, -1, &itemdb_read_itemtrade); + sv->readdb(db_path, "item_delay.txt", ',', 2, 2, -1, &itemdb_read_itemdelay); + sv->readdb(db_path, "item_stack.txt", ',', 3, 3, -1, &itemdb_read_stack); + sv->readdb(db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, &itemdb_read_buyingstore); + sv->readdb(db_path, "item_nouse.txt", ',', 3, 3, -1, &itemdb_read_nouse); itemdb_uid_load(); } @@ -1432,7 +1433,7 @@ void itemdb_reload(void) // readjust itemdb pointer cache for each player iter = mapit_geteachpc(); - for( sd = (struct map_session_data*)mapit_first(iter); mapit_exists(iter); sd = (struct map_session_data*)mapit_next(iter) ) { + for( sd = (struct map_session_data*)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data*)mapit->next(iter) ) { memset(sd->item_delay, 0, sizeof(sd->item_delay)); // reset item delays pc_setinventorydata(sd); /* clear combo bonuses */ @@ -1447,7 +1448,7 @@ void itemdb_reload(void) } } - mapit_free(iter); + mapit->free(iter); } void do_final_itemdb(void) diff --git a/src/map/log.c b/src/map/log.c index 1cca0a098..f57b91a2a 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -152,7 +152,7 @@ void log_branch(struct map_session_data* sd) { logs->branch_sub(sd); } void log_pick_sub_sql(int id, int16 m, e_log_pick_type type, int amount, struct item* itm, struct item_data *data) { - if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `unique_id`) VALUES (NOW(), '%d', '%c', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%"PRIu64"')", + if( SQL_ERROR == SQL->Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `unique_id`) VALUES (NOW(), '%d', '%c', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%"PRIu64"')", logs->config.log_pick, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"", itm->unique_id) ) { Sql_ShowDebug(logmysql_handle); @@ -197,7 +197,7 @@ void log_pick_mob(struct mob_data* md, e_log_pick_type type, int amount, struct log_pick(md->class_, md->bl.m, type, amount, itm, data ? data : itemdb_exists(itm->nameid)); } void log_zeny_sub_sql(struct map_session_data* sd, e_log_pick_type type, struct map_session_data* src_sd, int amount) { - if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%c', '%d', '%s')", + if( SQL_ERROR == SQL->Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%c', '%d', '%s')", logs->config.log_zeny, sd->status.char_id, src_sd->status.char_id, log_picktype2char(type), amount, mapindex_id2name(sd->mapindex)) ) { Sql_ShowDebug(logmysql_handle); @@ -227,7 +227,7 @@ void log_zeny(struct map_session_data* sd, e_log_pick_type type, struct map_sess logs->zeny_sub(sd,type,src_sd,amount); } void log_mvpdrop_sub_sql(struct map_session_data* sd, int monster_id, int* log_mvp) { - if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ", + if( SQL_ERROR == SQL->Query(logmysql_handle, LOG_QUERY " INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ", logs->config.log_mvpdrop, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], mapindex_id2name(sd->mapindex)) ) { Sql_ShowDebug(logmysql_handle); diff --git a/src/map/map.c b/src/map/map.c index 313abb2c6..5b0a4ed27 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -117,7 +117,6 @@ static int block_free_count = 0, block_free_lock = 0; static struct block_list *bl_list[BL_LIST_MAX]; static int bl_list_count = 0; -struct map_data map[MAX_MAP_PER_SERVER]; int map_num = 0; int map_port=0; @@ -1826,7 +1825,7 @@ struct map_session_data * map_nick2sd(const char *nick) iter = mapit_getallusers(); found_sd = NULL; - for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) ) + for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) { if( battle_config.partial_name_scan ) {// partial name search @@ -1849,7 +1848,7 @@ struct map_session_data * map_nick2sd(const char *nick) break; } } - mapit_free(iter); + mapit->free(iter); if( battle_config.partial_name_scan && qty != 1 ) found_sd = NULL; @@ -1902,8 +1901,7 @@ struct mob_data * map_id2boss(int id) /// Applies func to all the players in the db. /// Stops iterating if func returns -1. -void map_foreachpc(int (*func)(struct map_session_data* sd, va_list args), ...) -{ +void map_map_foreachpc(int (*func)(struct map_session_data* sd, va_list args), ...) { DBIterator* iter; struct map_session_data* sd; @@ -1924,7 +1922,7 @@ void map_foreachpc(int (*func)(struct map_session_data* sd, va_list args), ...) /// Applies func to all the mobs in the db. /// Stops iterating if func returns -1. -void map_foreachmob(int (*func)(struct mob_data* md, va_list args), ...) +void map_map_foreachmob(int (*func)(struct mob_data* md, va_list args), ...) { DBIterator* iter; struct mob_data* md; @@ -1946,7 +1944,7 @@ void map_foreachmob(int (*func)(struct mob_data* md, va_list args), ...) /// Applies func to all the npcs in the db. /// Stops iterating if func returns -1. -void map_foreachnpc(int (*func)(struct npc_data* nd, va_list args), ...) +void map_map_foreachnpc(int (*func)(struct npc_data* nd, va_list args), ...) { DBIterator* iter; struct block_list* bl; @@ -1972,7 +1970,7 @@ void map_foreachnpc(int (*func)(struct npc_data* nd, va_list args), ...) /// Applies func to everything in the db. /// Stops iteratin gif func returns -1. -void map_foreachregen(int (*func)(struct block_list* bl, va_list args), ...) +void map_map_foreachregen(int (*func)(struct block_list* bl, va_list args), ...) { DBIterator* iter; struct block_list* bl; @@ -1994,7 +1992,7 @@ void map_foreachregen(int (*func)(struct block_list* bl, va_list args), ...) /// Applies func to everything in the db. /// Stops iterating if func returns -1. -void map_foreachiddb(int (*func)(struct block_list* bl, va_list args), ...) +void map_map_foreachiddb(int (*func)(struct block_list* bl, va_list args), ...) { DBIterator* iter; struct block_list* bl; @@ -3169,14 +3167,13 @@ void map_removemapdb(struct map_data *m) /*====================================== * Initiate maps loading stage *--------------------------------------*/ -int map_readallmaps (void) -{ +int map_readallmaps (void) { int i; FILE* fp=NULL; int maps_removed = 0; char *map_cache_buffer = NULL; // Has the uncompressed gat data of all maps, so just one allocation has to be made char map_cache_decode_buffer[MAX_MAP_SIZE]; - + if( enable_grf ) ShowStatus("Loading maps (using GRF files)...\n"); else { @@ -3509,15 +3506,15 @@ int inter_config_read(char *cfgName) int map_sql_init(void) { // main db connection - mmysql_handle = Sql_Malloc(); + mmysql_handle = SQL->Malloc(); ShowInfo("Connecting to the Map DB Server....\n"); - if( SQL_ERROR == Sql_Connect(mmysql_handle, map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db) ) + if( SQL_ERROR == SQL->Connect(mmysql_handle, map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db) ) exit(EXIT_FAILURE); ShowStatus("connect success! (Map Server Connection)\n"); if( strlen(default_codepage) > 0 ) - if ( SQL_ERROR == Sql_SetEncoding(mmysql_handle, default_codepage) ) + if ( SQL_ERROR == SQL->SetEncoding(mmysql_handle, default_codepage) ) Sql_ShowDebug(mmysql_handle); return 0; @@ -3526,11 +3523,11 @@ int map_sql_init(void) int map_sql_close(void) { ShowStatus("Close Map DB Connection....\n"); - Sql_Free(mmysql_handle); + SQL->Free(mmysql_handle); mmysql_handle = NULL; if (logs->config.sql_logs) { ShowStatus("Close Log DB Connection....\n"); - Sql_Free(logmysql_handle); + SQL->Free(logmysql_handle); logmysql_handle = NULL; } return 0; @@ -3539,15 +3536,15 @@ int map_sql_close(void) int log_sql_init(void) { // log db connection - logmysql_handle = Sql_Malloc(); + logmysql_handle = SQL->Malloc(); ShowInfo(""CL_WHITE"[SQL]"CL_RESET": Connecting to the Log Database "CL_WHITE"%s"CL_RESET" At "CL_WHITE"%s"CL_RESET"...\n",log_db_db,log_db_ip); - if ( SQL_ERROR == Sql_Connect(logmysql_handle, log_db_id, log_db_pw, log_db_ip, log_db_port, log_db_db) ) + if ( SQL_ERROR == SQL->Connect(logmysql_handle, log_db_id, log_db_pw, log_db_ip, log_db_port, log_db_db) ) exit(EXIT_FAILURE); ShowStatus(""CL_WHITE"[SQL]"CL_RESET": Successfully '"CL_GREEN"connected"CL_RESET"' to Database '"CL_WHITE"%s"CL_RESET"'.\n", log_db_db); if( strlen(default_codepage) > 0 ) - if ( SQL_ERROR == Sql_SetEncoding(logmysql_handle, default_codepage) ) + if ( SQL_ERROR == SQL->SetEncoding(logmysql_handle, default_codepage) ) Sql_ShowDebug(logmysql_handle); return 0; } @@ -4934,9 +4931,9 @@ void do_final(void) //Ladies and babies first. iter = mapit_getallusers(); - for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) ) + for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) map_quit(sd); - mapit_free(iter); + mapit->free(iter); /* prepares npcs for a faster shutdown process */ do_clear_npc(); @@ -4996,6 +4993,8 @@ void do_final(void) map_sql_close(); ers_destroy(map_iterator_ers); + + aFree(map); ShowStatus("Finished.\n"); } @@ -5083,9 +5082,9 @@ void do_shutdown(void) { struct map_session_data* sd; struct s_mapiterator* iter = mapit_getallusers(); - for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) ) + for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) clif->GM_kick(NULL, sd); - mapit_free(iter); + mapit->free(iter); flush_fifos(); } chrif_check_shutdown(); @@ -5164,9 +5163,38 @@ void map_hp_symbols(void) { HPM->share(searchstore,"searchstore"); HPM->share(skill,"skill"); HPM->share(vending,"vending"); + /* partial */ + HPM->share(mapit,"mapit"); + HPM->share(map_foreachpc,"map_foreachpc"); + HPM->share(map_foreachmob,"map_foreachmob"); + HPM->share(map_foreachnpc,"map_foreachnpc"); + HPM->share(map_foreachregen,"map_foreachregen"); + HPM->share(map_foreachiddb,"map_foreachiddb"); + /* sql link */ + HPM->share(mmysql_handle,"sql_handle"); /* specific */ HPM->share(atcommand->create,"addCommand"); HPM->share(script->addScript,"addScript"); + /* vars */ + HPM->share(map,"map"); +} +/* temporary until the map.c "Hercules Renewal Phase One" design is complete. */ +void map_defaults(void) { + mapit = &mapit_s; + + mapit->alloc = mapit_alloc; + mapit->free = mapit_free; + mapit->first = mapit_first; + mapit->last = mapit_last; + mapit->next = mapit_next; + mapit->prev = mapit_prev; + mapit->exists = mapit_exists; + + map_foreachpc = map_map_foreachpc; + map_foreachmob = map_map_foreachmob; + map_foreachnpc = map_map_foreachnpc; + map_foreachregen = map_map_foreachregen; + map_foreachiddb = map_map_foreachiddb; } void load_defaults(void) { atcommand_defaults(); @@ -5176,6 +5204,7 @@ void load_defaults(void) { homunculus_defaults(); ircbot_defaults(); log_defaults(); + map_defaults(); script_defaults(); searchstore_defaults(); skill_defaults(); @@ -5286,6 +5315,8 @@ int do_init(int argc, char *argv[]) } } + CREATE(map,struct map_data,MAX_MAP_PER_SERVER); + load_defaults(); map_config_read(MAP_CONF_NAME); diff --git a/src/map/map.h b/src/map/map.h index a8ce19713..a7bcb08db 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -693,7 +693,7 @@ int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk); void map_setcell(int16 m, int16 x, int16 y, cell_t cell, bool flag); void map_setgatcell(int16 m, int16 x, int16 y, int gat); -extern struct map_data map[]; +struct map_data *map; extern int map_num; extern int autosave_interval; @@ -776,11 +776,13 @@ int map_eraseipport(unsigned short map, uint32 ip, uint16 port); int map_eraseallipport(void); void map_addiddb(struct block_list *); void map_deliddb(struct block_list *bl); -void map_foreachpc(int (*func)(struct map_session_data* sd, va_list args), ...); -void map_foreachmob(int (*func)(struct mob_data* md, va_list args), ...); -void map_foreachnpc(int (*func)(struct npc_data* nd, va_list args), ...); -void map_foreachregen(int (*func)(struct block_list* bl, va_list args), ...); -void map_foreachiddb(int (*func)(struct block_list* bl, va_list args), ...); +/* temporary until the map.c "Hercules Renewal Phase One" design is complete. */ +void (*map_foreachpc) (int (*func)(struct map_session_data* sd, va_list args), ...); +void (*map_foreachmob) (int (*func)(struct mob_data* md, va_list args), ...); +void (*map_foreachnpc) (int (*func)(struct npc_data* nd, va_list args), ...); +void (*map_foreachregen) (int (*func)(struct block_list* bl, va_list args), ...); +void (*map_foreachiddb) (int (*func)(struct block_list* bl, va_list args), ...); +/* */ struct map_session_data * map_nick2sd(const char*); struct mob_data * map_getmob_boss(int16 m); struct mob_data * map_id2boss(int id); @@ -789,24 +791,27 @@ struct mob_data * map_id2boss(int id); void map_reloadnpc(bool clear); /// Bitfield of flags for the iterator. -enum e_mapitflags -{ +enum e_mapitflags { MAPIT_NORMAL = 0, // MAPIT_PCISPLAYING = 1,// Unneeded as pc_db/id_db will only hold auth'ed, active players. }; struct s_mapiterator; -struct s_mapiterator* mapit_alloc(enum e_mapitflags flags, enum bl_type types); -void mapit_free(struct s_mapiterator* mapit); -struct block_list* mapit_first(struct s_mapiterator* mapit); -struct block_list* mapit_last(struct s_mapiterator* mapit); -struct block_list* mapit_next(struct s_mapiterator* mapit); -struct block_list* mapit_prev(struct s_mapiterator* mapit); -bool mapit_exists(struct s_mapiterator* mapit); -#define mapit_getallusers() mapit_alloc(MAPIT_NORMAL,BL_PC) -#define mapit_geteachpc() mapit_alloc(MAPIT_NORMAL,BL_PC) -#define mapit_geteachmob() mapit_alloc(MAPIT_NORMAL,BL_MOB) -#define mapit_geteachnpc() mapit_alloc(MAPIT_NORMAL,BL_NPC) -#define mapit_geteachiddb() mapit_alloc(MAPIT_NORMAL,BL_ALL) +/* temporary until the map.c "Hercules Renewal Phase One" design is complete. */ +struct mapit_interface { + struct s_mapiterator* (*alloc) (enum e_mapitflags flags, enum bl_type types); + void (*free) (struct s_mapiterator* mapit); + struct block_list* (*first) (struct s_mapiterator* mapit); + struct block_list* (*last) (struct s_mapiterator* mapit); + struct block_list* (*next) (struct s_mapiterator* mapit); + struct block_list* (*prev) (struct s_mapiterator* mapit); + bool (*exists) (struct s_mapiterator* mapit); +} mapit_s; +struct mapit_interface *mapit; +#define mapit_getallusers() mapit->alloc(MAPIT_NORMAL,BL_PC) +#define mapit_geteachpc() mapit->alloc(MAPIT_NORMAL,BL_PC) +#define mapit_geteachmob() mapit->alloc(MAPIT_NORMAL,BL_MOB) +#define mapit_geteachnpc() mapit->alloc(MAPIT_NORMAL,BL_NPC) +#define mapit_geteachiddb() mapit->alloc(MAPIT_NORMAL,BL_ALL) int map_check_dir(int s_dir,int t_dir); uint8 map_calc_dir( struct block_list *src,int16 x,int16 y); diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index bac3cea13..484da5641 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -62,8 +62,8 @@ bool mapreg_setreg(int uid, int val) { if(name[1] != '@') {// write new variable to database char tmp_str[32*2+1]; - Sql_EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32)); - if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapreg_table, tmp_str, i, val) ) + SQL->EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32)); + if( SQL_ERROR == SQL->Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapreg_table, tmp_str, i, val) ) Sql_ShowDebug(mmysql_handle); } idb_put(mapreg_db, uid, m); @@ -75,7 +75,7 @@ bool mapreg_setreg(int uid, int val) { idb_remove(mapreg_db,uid); if( name[1] != '@' ) {// Remove from database because it is unused. - if( SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, name, i) ) + if( SQL_ERROR == SQL->Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, name, i) ) Sql_ShowDebug(mmysql_handle); } } @@ -92,7 +92,7 @@ bool mapreg_setregstr(int uid, const char* str) { if( str == NULL || *str == 0 ) { if(name[1] != '@') { - if( SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, name, i) ) + if( SQL_ERROR == SQL->Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, name, i) ) Sql_ShowDebug(mmysql_handle); } if( (m = idb_get(mapregstr_db,uid)) ) { @@ -120,9 +120,9 @@ bool mapreg_setregstr(int uid, const char* str) { if(name[1] != '@') { //put returned null, so we must insert. char tmp_str[32*2+1]; char tmp_str2[255*2+1]; - Sql_EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32)); - Sql_EscapeStringLen(mmysql_handle, tmp_str2, str, strnlen(str, 255)); - if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%s')", mapreg_table, tmp_str, i, tmp_str2) ) + SQL->EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32)); + SQL->EscapeStringLen(mmysql_handle, tmp_str2, str, strnlen(str, 255)); + if( SQL_ERROR == SQL->Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%s')", mapreg_table, tmp_str, i, tmp_str2) ) Sql_ShowDebug(mmysql_handle); } idb_put(mapregstr_db, uid, m); @@ -206,7 +206,7 @@ static void script_save_mapreg(void) { int i = (m->uid & 0xff000000) >> 24; const char* name = get_str(num); - if( SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg_table, m->u.i, name, i) ) + if( SQL_ERROR == SQL->Query(mmysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg_table, m->u.i, name, i) ) Sql_ShowDebug(mmysql_handle); m->save = false; } @@ -224,8 +224,8 @@ static void script_save_mapreg(void) { const char* name = get_str(num); char tmp_str2[2*255+1]; - Sql_EscapeStringLen(mmysql_handle, tmp_str2, m->u.str, safestrnlen(m->u.str, 255)); - if( SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg_table, tmp_str2, name, i) ) + SQL->EscapeStringLen(mmysql_handle, tmp_str2, m->u.str, safestrnlen(m->u.str, 255)); + if( SQL_ERROR == SQL->Query(mmysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg_table, tmp_str2, name, i) ) Sql_ShowDebug(mmysql_handle); m->save = false; } diff --git a/src/map/mercenary.c b/src/map/mercenary.c index f673ae5de..02fcea891 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -456,7 +456,7 @@ static bool read_mercenarydb_sub(char* str[], int columns, int current) int read_mercenarydb(void) { memset(mercenary_db,0,sizeof(mercenary_db)); - sv_readdb(db_path, "mercenary_db.txt", ',', 26, 26, MAX_MERCENARY_CLASS, &read_mercenarydb_sub); + sv->readdb(db_path, "mercenary_db.txt", ',', 26, 26, MAX_MERCENARY_CLASS, &read_mercenarydb_sub); return 0; } @@ -494,7 +494,7 @@ static bool read_mercenary_skilldb_sub(char* str[], int columns, int current) int read_mercenary_skilldb(void) { - sv_readdb(db_path, "mercenary_skill_db.txt", ',', 3, 3, -1, &read_mercenary_skilldb_sub); + sv->readdb(db_path, "mercenary_skill_db.txt", ',', 3, 3, -1, &read_mercenary_skilldb_sub); return 0; } diff --git a/src/map/mob.c b/src/map/mob.c index 86c0f8455..0f1ad0452 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -3907,7 +3907,7 @@ static void mob_readdb(void) } } - sv_readdb(db_path, filename[fi], ',', 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, -1, &mob_readdb_sub); + sv->readdb(db_path, filename[fi], ',', 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, -1, &mob_readdb_sub); } } @@ -3923,13 +3923,13 @@ static int mob_read_sqldb(void) uint32 lines = 0, count = 0; // retrieve all rows from the mob database - if( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT * FROM `%s`", mob_db_name[fi]) ) { + if( SQL_ERROR == SQL->Query(mmysql_handle, "SELECT * FROM `%s`", mob_db_name[fi]) ) { Sql_ShowDebug(mmysql_handle); continue; } // process rows one by one - while( SQL_SUCCESS == Sql_NextRow(mmysql_handle) ) { + while( SQL_SUCCESS == SQL->NextRow(mmysql_handle) ) { // wrap the result into a TXT-compatible format char line[1024]; char* str[31+2*MAX_MVP_DROP+2*MAX_MOB_DROP]; @@ -3941,7 +3941,7 @@ static int mob_read_sqldb(void) { char* data; size_t len; - Sql_GetData(mmysql_handle, i, &data, &len); + SQL->GetData(mmysql_handle, i, &data, &len); strcpy(p, data); str[i] = p; @@ -3955,7 +3955,7 @@ static int mob_read_sqldb(void) } // free the query result - Sql_FreeResult(mmysql_handle); + SQL->FreeResult(mmysql_handle); ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, mob_db_name[fi]); } @@ -4471,7 +4471,7 @@ static void mob_readskilldb(void) { } } - sv_readdb(db_path, filename[fi], ',', 19, 19, -1, &mob_parse_row_mobskilldb); + sv->readdb(db_path, filename[fi], ',', 19, 19, -1, &mob_parse_row_mobskilldb); } } @@ -4495,13 +4495,13 @@ static int mob_read_sqlskilldb(void) uint32 lines = 0, count = 0; // retrieve all rows from the mob skill database - if( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT * FROM `%s`", mob_skill_db_name[fi]) ) { + if( SQL_ERROR == SQL->Query(mmysql_handle, "SELECT * FROM `%s`", mob_skill_db_name[fi]) ) { Sql_ShowDebug(mmysql_handle); continue; } // process rows one by one - while( SQL_SUCCESS == Sql_NextRow(mmysql_handle) ) { + while( SQL_SUCCESS == SQL->NextRow(mmysql_handle) ) { // wrap the result into a TXT-compatible format char* str[19]; char* dummy = ""; @@ -4509,7 +4509,7 @@ static int mob_read_sqlskilldb(void) ++lines; for( i = 0; i < 19; ++i ) { - Sql_GetData(mmysql_handle, i, &str[i], NULL); + SQL->GetData(mmysql_handle, i, &str[i], NULL); if( str[i] == NULL ) str[i] = dummy; // get rid of NULL columns } @@ -4520,7 +4520,7 @@ static int mob_read_sqlskilldb(void) } // free the query result - Sql_FreeResult(mmysql_handle); + SQL->FreeResult(mmysql_handle); ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, mob_skill_db_name[fi]); } @@ -4586,7 +4586,7 @@ static bool mob_readdb_itemratio(char* str[], int columns, int current) */ static void mob_load(void) { - sv_readdb(db_path, "mob_item_ratio.txt", ',', 2, 2+MAX_ITEMRATIO_MOBS, -1, &mob_readdb_itemratio); // must be read before mobdb + sv->readdb(db_path, "mob_item_ratio.txt", ',', 2, 2+MAX_ITEMRATIO_MOBS, -1, &mob_readdb_itemratio); // must be read before mobdb mob_readchatdb(); if (db_use_sqldbs) { @@ -4598,9 +4598,9 @@ static void mob_load(void) mob_readdb(); mob_readskilldb(); } - sv_readdb(db_path, "mob_avail.txt", ',', 2, 12, -1, &mob_readdb_mobavail); + sv->readdb(db_path, "mob_avail.txt", ',', 2, 12, -1, &mob_readdb_mobavail); mob_read_randommonster(); - sv_readdb(db_path, DBPATH"mob_race2_db.txt", ',', 2, 20, -1, &mob_readdb_race2); + sv->readdb(db_path, DBPATH"mob_race2_db.txt", ',', 2, 20, -1, &mob_readdb_race2); } void mob_reload(void) { diff --git a/src/map/npc.c b/src/map/npc.c index a9fdb5ea6..3a3ae472d 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1852,7 +1852,7 @@ int npc_unload(struct npc_data* nd, bool single) { ev_db->foreach(ev_db,npc_unload_ev,nd->exname); //Clean up all events related iter = mapit_geteachpc(); - for( bl = (struct block_list*)mapit_first(iter); mapit_exists(iter); bl = (struct block_list*)mapit_next(iter) ) { + for( bl = (struct block_list*)mapit->first(iter); mapit->exists(iter); bl = (struct block_list*)mapit->next(iter) ) { struct map_session_data *sd = ((TBL_PC*)bl); if( sd && sd->npc_timer_id != INVALID_TIMER ) { const struct TimerData *td = get_timer(sd->npc_timer_id); @@ -1866,7 +1866,7 @@ int npc_unload(struct npc_data* nd, bool single) { sd->npc_timer_id = INVALID_TIMER; } } - mapit_free(iter); + mapit->free(iter); if (nd->u.scr.timerid != INVALID_TIMER) { const struct TimerData *td; @@ -3606,7 +3606,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit) lines++; // w1w2w3w4 - count = sv_parse(p, len+buffer-p, 0, '\t', pos, ARRAYLENGTH(pos), (e_svopt)(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)); @@ -3836,7 +3836,7 @@ int npc_reload(void) { //Remove all npcs/mobs. [Skotlex] iter = mapit_geteachiddb(); - for( bl = (struct block_list*)mapit_first(iter); mapit_exists(iter); bl = (struct block_list*)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: if( bl->id != fake_nd->bl.id )// don't remove fake_nd @@ -3847,7 +3847,7 @@ int npc_reload(void) { break; } } - mapit_free(iter); + mapit->free(iter); if(battle_config.dynamic_mobs) {// dynamic check by [random] diff --git a/src/map/pc.c b/src/map/pc.c index 7d3b5c4a2..50188aeb3 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -9115,7 +9115,7 @@ int pc_autosave(int tid, unsigned int tick, int id, intptr_t data) save_flag = 1; //Noone was saved, so save first found char. iter = mapit_getallusers(); - for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) ) + for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) { if(sd->bl.id == last_save_id && save_flag != 1) { save_flag = 1; @@ -9132,7 +9132,7 @@ int pc_autosave(int tid, unsigned int tick, int id, intptr_t data) chrif_save(sd,0); break; } - mapit_free(iter); + mapit->free(iter); interval = autosave_interval/(map_usercount()+1); if(interval < minsave_interval) @@ -9620,10 +9620,10 @@ int pc_readdb(void) count = 0; // Reset and read skilltree memset(skill_tree,0,sizeof(skill_tree)); - sv_readdb(db_path, DBPATH"skill_tree.txt", ',', 3+MAX_PC_SKILL_REQUIRE*2, 4+MAX_PC_SKILL_REQUIRE*2, -1, &pc_readdb_skilltree); + sv->readdb(db_path, DBPATH"skill_tree.txt", ',', 3+MAX_PC_SKILL_REQUIRE*2, 4+MAX_PC_SKILL_REQUIRE*2, -1, &pc_readdb_skilltree); #if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) - sv_readdb(db_path, "re/level_penalty.txt", ',', 4, 4, -1, &pc_readdb_levelpenalty); + sv->readdb(db_path, "re/level_penalty.txt", ',', 4, 4, -1, &pc_readdb_levelpenalty); for( k=1; k < 3; k++ ){ // fill in the blanks for( j = 0; j < RC_MAX; j++ ){ int tmp = 0; diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c index 42a068693..1a83c8b63 100644 --- a/src/map/pc_groups.c +++ b/src/map/pc_groups.c @@ -452,10 +452,10 @@ void pc_groups_reload(void) { /* refresh online users permissions */ iter = mapit_getallusers(); - for (sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter)) { + for (sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter)) { pc_group_pc_load(sd); } - mapit_free(iter); + mapit->free(iter); } diff --git a/src/map/script.c b/src/map/script.c index fd2e2654f..3d5045f02 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -1095,18 +1095,16 @@ const char* parse_simpleexpr(const char *p) add_scriptc(C_STR); p++; while( *p && *p != '"' ){ - if( (unsigned char)p[-1] <= 0x7e && *p == '\\' ) - { + if( (unsigned char)p[-1] <= 0x7e && *p == '\\' ) { char buf[8]; - size_t len = skip_escaped_c(p) - p; - size_t n = sv_unescape_c(buf, p, len); + size_t len = sv->skip_escaped_c(p) - p; + size_t n = sv->unescape_c(buf, p, len); if( n != 1 ) ShowDebug("parse_simpleexpr: unexpected length %d after unescape (\"%.*s\" -> %.*s)\n", (int)n, (int)len, p, (int)n, buf); p += len; add_scriptb(*buf); continue; - } - else if( *p == '\n' ) + } else if( *p == '\n' ) disp_error_message("parse_simpleexpr: unexpected newline @ string",p); add_scriptb(*p++); } @@ -2040,16 +2038,16 @@ static const char* script_print_line(StringBuf* buf, const char* p, const char* int i; if( p == NULL || !p[0] ) return NULL; if( line < 0 ) - StringBuf_Printf(buf, "*% 5d : ", -line); + StrBuf->Printf(buf, "*% 5d : ", -line); else - StringBuf_Printf(buf, " % 5d : ", line); + StrBuf->Printf(buf, " % 5d : ", line); for(i=0;p[i] && p[i] != '\n';i++){ if(p + i != mark) - StringBuf_Printf(buf, "%c", p[i]); + StrBuf->Printf(buf, "%c", p[i]); else - StringBuf_Printf(buf, "\'%c\'", p[i]); + StrBuf->Printf(buf, "\'%c\'", p[i]); } - StringBuf_AppendStr(buf, "\n"); + StrBuf->AppendStr(buf, "\n"); return p+i+(p[i] == '\n' ? 1 : 0); } @@ -2074,10 +2072,10 @@ void script_error(const char* src, const char* file, int start_line, const char* p=lineend+1; } - StringBuf_Init(&buf); - StringBuf_AppendStr(&buf, "\a\n"); - StringBuf_Printf(&buf, "script error on %s line %d\n", file, line); - StringBuf_Printf(&buf, " %s\n", error_msg); + StrBuf->Init(&buf); + StrBuf->AppendStr(&buf, "\a\n"); + StrBuf->Printf(&buf, "script error on %s line %d\n", file, line); + StrBuf->Printf(&buf, " %s\n", error_msg); for(j = 0; j < 5; j++ ) { script_print_line(&buf, linestart[j], NULL, line + j - 5); } @@ -2085,8 +2083,8 @@ void script_error(const char* src, const char* file, int start_line, const char* for(j = 0; j < 5; j++) { p = script_print_line(&buf, p, NULL, line + j + 1 ); } - ShowError("%s", StringBuf_Value(&buf)); - StringBuf_Destroy(&buf); + ShowError("%s", StrBuf->Value(&buf)); + StrBuf->Destroy(&buf); } /*========================================== @@ -4062,7 +4060,7 @@ BUILDIN(menu) return false; } - StringBuf_Init(&buf); + StrBuf->Init(&buf); sd->npc_menu = 0; for( i = 2; i < script_lastdata(st); i += 2 ) { @@ -4073,7 +4071,7 @@ BUILDIN(menu) data = script_getdata(st, i+1); if( !data_islabel(data) ) {// not a label - StringBuf_Destroy(&buf); + StrBuf->Destroy(&buf); ShowError("script:menu: argument #%d (from 1) is not a label or label not found.\n", i); script_reportdata(data); st->state = END; @@ -4084,8 +4082,8 @@ BUILDIN(menu) if( text[0] == '\0' ) continue;// empty string, ignore if( sd->npc_menu > 0 ) - StringBuf_AppendStr(&buf, ":"); - StringBuf_AppendStr(&buf, text); + StrBuf->AppendStr(&buf, ":"); + StrBuf->AppendStr(&buf, text); sd->npc_menu += menu_countoptions(text, 0, NULL); } st->state = RERUNLINE; @@ -4094,18 +4092,18 @@ BUILDIN(menu) /** * menus beyond this length crash the client (see bugreport:6402) **/ - if( StringBuf_Length(&buf) >= 2047 ) { + if( StrBuf->Length(&buf) >= 2047 ) { struct npc_data * nd = map_id2nd(st->oid); char* menu; CREATE(menu, char, 2048); - safestrncpy(menu, StringBuf_Value(&buf), 2047); - ShowWarning("NPC Menu too long! (source:%s / length:%d)\n",nd?nd->name:"Unknown",StringBuf_Length(&buf)); + safestrncpy(menu, StrBuf->Value(&buf), 2047); + ShowWarning("NPC Menu too long! (source:%s / length:%d)\n",nd?nd->name:"Unknown",StrBuf->Length(&buf)); clif->scriptmenu(sd, st->oid, menu); aFree(menu); } else - clif->scriptmenu(sd, st->oid, StringBuf_Value(&buf)); + clif->scriptmenu(sd, st->oid, StrBuf->Value(&buf)); - StringBuf_Destroy(&buf); + StrBuf->Destroy(&buf); if( sd->npc_menu >= 0xff ) {// client supports only up to 254 entries; 0 is not used and 255 is reserved for cancel; excess entries are displayed but cause 'uint8' overflow @@ -4181,15 +4179,15 @@ BUILDIN(select) if( sd->state.menu_or_input == 0 ) { struct StringBuf buf; - StringBuf_Init(&buf); + StrBuf->Init(&buf); sd->npc_menu = 0; for( i = 2; i <= script_lastdata(st); ++i ) { text = script_getstr(st, i); if( sd->npc_menu > 0 ) - StringBuf_AppendStr(&buf, ":"); + StrBuf->AppendStr(&buf, ":"); - StringBuf_AppendStr(&buf, text); + StrBuf->AppendStr(&buf, text); sd->npc_menu += menu_countoptions(text, 0, NULL); } @@ -4199,17 +4197,17 @@ BUILDIN(select) /** * menus beyond this length crash the client (see bugreport:6402) **/ - if( StringBuf_Length(&buf) >= 2047 ) { + if( StrBuf->Length(&buf) >= 2047 ) { struct npc_data * nd = map_id2nd(st->oid); char* menu; CREATE(menu, char, 2048); - safestrncpy(menu, StringBuf_Value(&buf), 2047); - ShowWarning("NPC Menu too long! (source:%s / length:%d)\n",nd?nd->name:"Unknown",StringBuf_Length(&buf)); + safestrncpy(menu, StrBuf->Value(&buf), 2047); + ShowWarning("NPC Menu too long! (source:%s / length:%d)\n",nd?nd->name:"Unknown",StrBuf->Length(&buf)); clif->scriptmenu(sd, st->oid, menu); aFree(menu); } else - clif->scriptmenu(sd, st->oid, StringBuf_Value(&buf)); - StringBuf_Destroy(&buf); + clif->scriptmenu(sd, st->oid, StrBuf->Value(&buf)); + StrBuf->Destroy(&buf); if( sd->npc_menu >= 0xff ) { ShowWarning("buildin_select: Too many options specified (current=%d, max=254).\n", sd->npc_menu); @@ -4261,14 +4259,14 @@ BUILDIN(prompt) { struct StringBuf buf; - StringBuf_Init(&buf); + StrBuf->Init(&buf); sd->npc_menu = 0; for( i = 2; i <= script_lastdata(st); ++i ) { text = script_getstr(st, i); if( sd->npc_menu > 0 ) - StringBuf_AppendStr(&buf, ":"); - StringBuf_AppendStr(&buf, text); + StrBuf->AppendStr(&buf, ":"); + StrBuf->AppendStr(&buf, text); sd->npc_menu += menu_countoptions(text, 0, NULL); } @@ -4278,17 +4276,17 @@ BUILDIN(prompt) /** * menus beyond this length crash the client (see bugreport:6402) **/ - if( StringBuf_Length(&buf) >= 2047 ) { + if( StrBuf->Length(&buf) >= 2047 ) { struct npc_data * nd = map_id2nd(st->oid); char* menu; CREATE(menu, char, 2048); - safestrncpy(menu, StringBuf_Value(&buf), 2047); - ShowWarning("NPC Menu too long! (source:%s / length:%d)\n",nd?nd->name:"Unknown",StringBuf_Length(&buf)); + safestrncpy(menu, StrBuf->Value(&buf), 2047); + ShowWarning("NPC Menu too long! (source:%s / length:%d)\n",nd?nd->name:"Unknown",StrBuf->Length(&buf)); clif->scriptmenu(sd, st->oid, menu); aFree(menu); } else - clif->scriptmenu(sd, st->oid, StringBuf_Value(&buf)); - StringBuf_Destroy(&buf); + clif->scriptmenu(sd, st->oid, StrBuf->Value(&buf)); + StrBuf->Destroy(&buf); if( sd->npc_menu >= 0xff ) { @@ -4834,7 +4832,7 @@ BUILDIN(warpguild) } iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { if( pl_sd->status.guild_id != gid ) continue; @@ -4859,7 +4857,7 @@ BUILDIN(warpguild) break; } } - mapit_free(iter); + mapit->free(iter); return true; } @@ -9292,7 +9290,7 @@ BUILDIN(getusersname) group_level = pc_get_group_level(sd); iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { if (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc_get_group_level(pl_sd) > group_level) continue; // skip hidden sessions @@ -9303,7 +9301,7 @@ BUILDIN(getusersname) clif->scriptnext(sd,st->oid);*/ clif->scriptmes(sd,st->oid,pl_sd->status.name); } - mapit_free(iter); + mapit->free(iter); return true; } @@ -10567,7 +10565,7 @@ BUILDIN(pvpon) return true; iter = mapit_getallusers(); - for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) ) + for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) { if( sd->bl.m != m || sd->pvp_timer != INVALID_TIMER ) continue; // not applicable @@ -10579,7 +10577,7 @@ BUILDIN(pvpon) sd->pvp_won = 0; sd->pvp_lost = 0; } - mapit_free(iter); + mapit->free(iter); return true; } @@ -12303,7 +12301,7 @@ BUILDIN(recovery) struct s_mapiterator* iter; iter = mapit_getallusers(); - for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) ) + for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) { if(pc_isdead(sd)) status_revive(&sd->bl, 100, 100); @@ -12311,7 +12309,7 @@ BUILDIN(recovery) status_percent_heal(&sd->bl, 100, 100); clif->message(sd->fd,msg_txt(680)); } - mapit_free(iter); + mapit->free(iter); return true; } /*========================================== @@ -13596,7 +13594,7 @@ BUILDIN(sprintf) safestrncpy(buf, format, len+1); // Issue sprintf for each parameter - StringBuf_Init(&final_buf); + StrBuf->Init(&final_buf); q = buf; while((p = strchr(q, '%'))!=NULL){ if(p!=q){ @@ -13606,12 +13604,12 @@ BUILDIN(sprintf) buf2_len = len; } safestrncpy(buf2, q, len); - StringBuf_AppendStr(&final_buf, buf2); + StrBuf->AppendStr(&final_buf, buf2); q = p; } p = q+1; if(*p=='%'){ // %% - StringBuf_AppendStr(&final_buf, "%"); + StrBuf->AppendStr(&final_buf, "%"); q+=2; continue; } @@ -13625,7 +13623,7 @@ BUILDIN(sprintf) ShowError("buildin_sprintf: Not enough arguments passed!\n"); if(buf) aFree(buf); if(buf2) aFree(buf2); - StringBuf_Destroy(&final_buf); + StrBuf->Destroy(&final_buf); script_pushconststr(st,""); return false; } @@ -13647,21 +13645,21 @@ BUILDIN(sprintf) // the scripter's responsibility. data = script_getdata(st, arg+3); if(data_isstring(data)){ // String - StringBuf_Printf(&final_buf, buf2, script_getstr(st, arg+3)); + StrBuf->Printf(&final_buf, buf2, script_getstr(st, arg+3)); }else if(data_isint(data)){ // Number - StringBuf_Printf(&final_buf, buf2, script_getnum(st, arg+3)); + StrBuf->Printf(&final_buf, buf2, script_getnum(st, arg+3)); }else if(data_isreference(data)){ // Variable char* name = reference_getname(data); if(name[strlen(name)-1]=='$'){ // var Str - StringBuf_Printf(&final_buf, buf2, script_getstr(st, arg+3)); + StrBuf->Printf(&final_buf, buf2, script_getstr(st, arg+3)); }else{ // var Int - StringBuf_Printf(&final_buf, buf2, script_getnum(st, arg+3)); + StrBuf->Printf(&final_buf, buf2, script_getnum(st, arg+3)); } }else{ // Unsupported type ShowError("buildin_sprintf: Unknown argument type!\n"); if(buf) aFree(buf); if(buf2) aFree(buf2); - StringBuf_Destroy(&final_buf); + StrBuf->Destroy(&final_buf); script_pushconststr(st,""); return false; } @@ -13670,7 +13668,7 @@ BUILDIN(sprintf) // Append anything left if(*q){ - StringBuf_AppendStr(&final_buf, q); + StrBuf->AppendStr(&final_buf, q); } // Passed more, than needed @@ -13679,11 +13677,11 @@ BUILDIN(sprintf) script_reportsrc(st); } - script_pushstrcopy(st, StringBuf_Value(&final_buf)); + script_pushstrcopy(st, StrBuf->Value(&final_buf)); if(buf) aFree(buf); if(buf2) aFree(buf2); - StringBuf_Destroy(&final_buf); + StrBuf->Destroy(&final_buf); return true; } @@ -13878,7 +13876,7 @@ BUILDIN(replacestr) } } - StringBuf_Init(&output); + StrBuf->Init(&output); for(; i < inputlen; i++) { if(count && count == numFinds) { //found enough, stop looking @@ -13888,19 +13886,19 @@ BUILDIN(replacestr) for(f = 0; f <= findlen; f++) { if(f == findlen) { //complete match numFinds++; - StringBuf_AppendStr(&output, replace); + StrBuf->AppendStr(&output, replace); i += findlen - 1; break; } else { if(usecase) { if((i + f) > inputlen || input[i + f] != find[f]) { - StringBuf_Printf(&output, "%c", input[i]); + StrBuf->Printf(&output, "%c", input[i]); break; } } else { if(((i + f) > inputlen || input[i + f] != find[f]) && TOUPPER(input[i+f]) != TOUPPER(find[f])) { - StringBuf_Printf(&output, "%c", input[i]); + StrBuf->Printf(&output, "%c", input[i]); break; } } @@ -13910,10 +13908,10 @@ BUILDIN(replacestr) //append excess after enough found if(i < inputlen) - StringBuf_AppendStr(&output, &(input[i])); + StrBuf->AppendStr(&output, &(input[i])); - script_pushstrcopy(st, StringBuf_Value(&output)); - StringBuf_Destroy(&output); + script_pushstrcopy(st, StrBuf->Value(&output)); + StrBuf->Destroy(&output); return true; } @@ -14173,20 +14171,20 @@ int buildin_query_sql_sub(struct script_state* st, Sql* handle) // Execute the query query = script_getstr(st,2); - if( SQL_ERROR == Sql_QueryStr(handle, query) ) { + if( SQL_ERROR == SQL->QueryStr(handle, query) ) { Sql_ShowDebug(handle); script_pushint(st, 0); return false; } - if( Sql_NumRows(handle) == 0 ) { // No data received - Sql_FreeResult(handle); + if( SQL->NumRows(handle) == 0 ) { // No data received + SQL->FreeResult(handle); script_pushint(st, 0); return true; } // Count the number of columns to store - num_cols = Sql_NumColumns(handle); + num_cols = SQL->NumColumns(handle); if( num_vars < num_cols ) { ShowWarning("script:query_sql: Too many columns, discarding last %u columns.\n", (unsigned int)(num_cols-num_vars)); script_reportsrc(st); @@ -14196,12 +14194,12 @@ int buildin_query_sql_sub(struct script_state* st, Sql* handle) } // Store data - for( i = 0; i < max_rows && SQL_SUCCESS == Sql_NextRow(handle); ++i ) { + for( i = 0; i < max_rows && SQL_SUCCESS == SQL->NextRow(handle); ++i ) { for( j = 0; j < num_vars; ++j ) { char* str = NULL; if( j < num_cols ) - Sql_GetData(handle, j, &str, NULL); + SQL->GetData(handle, j, &str, NULL); data = script_getdata(st, j+3); name = reference_getname(data); @@ -14211,13 +14209,13 @@ int buildin_query_sql_sub(struct script_state* st, Sql* handle) setd_sub(st, sd, name, i, (void *)__64BPTRSIZE((str?atoi(str):0)), reference_getref(data)); } } - if( i == max_rows && max_rows < Sql_NumRows(handle) ) { - ShowWarning("script:query_sql: Only %d/%u rows have been stored.\n", max_rows, (unsigned int)Sql_NumRows(handle)); + if( i == max_rows && max_rows < SQL->NumRows(handle) ) { + ShowWarning("script:query_sql: Only %d/%u rows have been stored.\n", max_rows, (unsigned int)SQL->NumRows(handle)); script_reportsrc(st); } // Free data - Sql_FreeResult(handle); + SQL->FreeResult(handle); script_pushint(st, i); return true; @@ -14245,7 +14243,7 @@ BUILDIN(escape_sql) str = script_getstr(st,2); len = strlen(str); esc_str = (char*)aMalloc(len*2+1); - Sql_EscapeStringLen(mmysql_handle, esc_str, str, len); + SQL->EscapeStringLen(mmysql_handle, esc_str, str, len); script_pushstr(st, esc_str); return true; } @@ -15006,12 +15004,12 @@ BUILDIN(unittalk) if( bl != NULL ) { struct StringBuf sbuf; - StringBuf_Init(&sbuf); - StringBuf_Printf(&sbuf, "%s : %s", status_get_name(bl), message); - clif->disp_overhead(bl, StringBuf_Value(&sbuf)); + StrBuf->Init(&sbuf); + StrBuf->Printf(&sbuf, "%s : %s", status_get_name(bl), message); + clif->disp_overhead(bl, StrBuf->Value(&sbuf)); if( bl->type == BL_PC ) - clif->message(((TBL_PC*)bl)->fd, StringBuf_Value(&sbuf)); - StringBuf_Destroy(&sbuf); + clif->message(((TBL_PC*)bl)->fd, StrBuf->Value(&sbuf)); + StrBuf->Destroy(&sbuf); } return true; diff --git a/src/map/skill.c b/src/map/skill.c index 828d600c1..d10cdb1a9 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -17770,27 +17770,27 @@ void skill_readdb(void) { safestrncpy(skill_db[0].name, "UNKNOWN_SKILL", sizeof(skill_db[0].name)); safestrncpy(skill_db[0].desc, "Unknown Skill", sizeof(skill_db[0].desc)); - sv_readdb(db_path, DBPATH"skill_db.txt" , ',', 17, 17, MAX_SKILL_DB, skill->parse_row_skilldb); - sv_readdb(db_path, DBPATH"skill_require_db.txt" , ',', 32, 32, MAX_SKILL_DB, skill->parse_row_requiredb); + sv->readdb(db_path, DBPATH"skill_db.txt" , ',', 17, 17, MAX_SKILL_DB, skill->parse_row_skilldb); + sv->readdb(db_path, DBPATH"skill_require_db.txt" , ',', 32, 32, MAX_SKILL_DB, skill->parse_row_requiredb); #ifdef RENEWAL_CAST - sv_readdb(db_path, "re/skill_cast_db.txt" , ',', 8, 8, MAX_SKILL_DB, skill->parse_row_castdb); + sv->readdb(db_path, "re/skill_cast_db.txt" , ',', 8, 8, MAX_SKILL_DB, skill->parse_row_castdb); #else - sv_readdb(db_path, "pre-re/skill_cast_db.txt" , ',', 7, 7, MAX_SKILL_DB, skill->parse_row_castdb); + sv->readdb(db_path, "pre-re/skill_cast_db.txt" , ',', 7, 7, MAX_SKILL_DB, skill->parse_row_castdb); #endif - sv_readdb(db_path, DBPATH"skill_castnodex_db.txt", ',', 2, 3, MAX_SKILL_DB, skill->parse_row_castnodexdb); - sv_readdb(db_path, DBPATH"skill_unit_db.txt" , ',', 8, 8, MAX_SKILL_DB, skill->parse_row_unitdb); + sv->readdb(db_path, DBPATH"skill_castnodex_db.txt", ',', 2, 3, MAX_SKILL_DB, skill->parse_row_castnodexdb); + sv->readdb(db_path, DBPATH"skill_unit_db.txt" , ',', 8, 8, MAX_SKILL_DB, skill->parse_row_unitdb); skill->init_unit_layout(); - sv_readdb(db_path, "produce_db.txt" , ',', 4, 4+2*MAX_PRODUCE_RESOURCE, MAX_SKILL_PRODUCE_DB, skill->parse_row_producedb); - sv_readdb(db_path, "create_arrow_db.txt" , ',', 1+2, 1+2*MAX_ARROW_RESOURCE, MAX_SKILL_ARROW_DB, skill->parse_row_createarrowdb); - sv_readdb(db_path, "abra_db.txt" , ',', 4, 4, MAX_SKILL_ABRA_DB, skill->parse_row_abradb); + sv->readdb(db_path, "produce_db.txt" , ',', 4, 4+2*MAX_PRODUCE_RESOURCE, MAX_SKILL_PRODUCE_DB, skill->parse_row_producedb); + sv->readdb(db_path, "create_arrow_db.txt" , ',', 1+2, 1+2*MAX_ARROW_RESOURCE, MAX_SKILL_ARROW_DB, skill->parse_row_createarrowdb); + sv->readdb(db_path, "abra_db.txt" , ',', 4, 4, MAX_SKILL_ABRA_DB, skill->parse_row_abradb); //Warlock - sv_readdb(db_path, "spellbook_db.txt" , ',', 3, 3, MAX_SKILL_SPELLBOOK_DB, skill->parse_row_spellbookdb); + sv->readdb(db_path, "spellbook_db.txt" , ',', 3, 3, MAX_SKILL_SPELLBOOK_DB, skill->parse_row_spellbookdb); //Guillotine Cross - sv_readdb(db_path, "magicmushroom_db.txt" , ',', 1, 1, MAX_SKILL_MAGICMUSHROOM_DB, skill->parse_row_magicmushroomdb); - sv_readdb(db_path, "skill_reproduce_db.txt", ',', 1, 1, MAX_SKILL_DB, skill->parse_row_reproducedb); - sv_readdb(db_path, "skill_improvise_db.txt" , ',', 2, 2, MAX_SKILL_IMPROVISE_DB, skill->parse_row_improvisedb); - sv_readdb(db_path, "skill_changematerial_db.txt" , ',', 4, 4+2*5, MAX_SKILL_PRODUCE_DB, skill->parse_row_changematerialdb); + sv->readdb(db_path, "magicmushroom_db.txt" , ',', 1, 1, MAX_SKILL_MAGICMUSHROOM_DB, skill->parse_row_magicmushroomdb); + sv->readdb(db_path, "skill_reproduce_db.txt", ',', 1, 1, MAX_SKILL_DB, skill->parse_row_reproducedb); + sv->readdb(db_path, "skill_improvise_db.txt" , ',', 2, 2, MAX_SKILL_IMPROVISE_DB, skill->parse_row_improvisedb); + sv->readdb(db_path, "skill_changematerial_db.txt" , ',', 4, 4+2*5, MAX_SKILL_PRODUCE_DB, skill->parse_row_changematerialdb); } void skill_reload (void) { @@ -17815,9 +17815,9 @@ void skill_reload (void) { chrif_skillid2idx(0); /* lets update all players skill tree : so that if any skill modes were changed they're properly updated */ iter = mapit_getallusers(); - for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) ) + for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) clif->skillinfoblock(sd); - mapit_free(iter); + mapit->free(iter); } diff --git a/src/map/status.c b/src/map/status.c index f13c1ce3a..9fbfe26fe 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -11282,13 +11282,13 @@ int status_readdb(void) #ifdef RENEWAL_ASPD - sv_readdb(db_path, "re/job_db1.txt", ',', 6+MAX_WEAPON_TYPE, 6+MAX_WEAPON_TYPE, -1, &status_readdb_job1); + sv->readdb(db_path, "re/job_db1.txt", ',', 6+MAX_WEAPON_TYPE, 6+MAX_WEAPON_TYPE, -1, &status_readdb_job1); #else - sv_readdb(db_path, "pre-re/job_db1.txt", ',', 5+MAX_WEAPON_TYPE, 5+MAX_WEAPON_TYPE, -1, &status_readdb_job1); + sv->readdb(db_path, "pre-re/job_db1.txt", ',', 5+MAX_WEAPON_TYPE, 5+MAX_WEAPON_TYPE, -1, &status_readdb_job1); #endif - sv_readdb(db_path, "job_db2.txt", ',', 1, 1+MAX_LEVEL, -1, &status_readdb_job2); - sv_readdb(db_path, "size_fix.txt", ',', MAX_WEAPON_TYPE, MAX_WEAPON_TYPE, ARRAYLENGTH(atkmods), &status_readdb_sizefix); - sv_readdb(db_path, DBPATH"refine_db.txt", ',', 4+MAX_REFINE, 4+MAX_REFINE, ARRAYLENGTH(refine_info), &status_readdb_refine); + sv->readdb(db_path, "job_db2.txt", ',', 1, 1+MAX_LEVEL, -1, &status_readdb_job2); + sv->readdb(db_path, "size_fix.txt", ',', MAX_WEAPON_TYPE, MAX_WEAPON_TYPE, ARRAYLENGTH(atkmods), &status_readdb_sizefix); + sv->readdb(db_path, DBPATH"refine_db.txt", ',', 4+MAX_REFINE, 4+MAX_REFINE, ARRAYLENGTH(refine_info), &status_readdb_refine); return 0; } -- cgit v1.2.3-60-g2f50