summaryrefslogtreecommitdiff
path: root/src/map/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/map.c')
-rw-r--r--src/map/map.c45
1 files changed, 17 insertions, 28 deletions
diff --git a/src/map/map.c b/src/map/map.c
index 40261ebbc..ce8f4cdf5 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -59,6 +59,7 @@
#include "map/rodex.h"
#include "map/trade.h"
#include "map/unit.h"
+#include "map/achievement.h"
#include "common/HPM.h"
#include "common/cbasetypes.h"
#include "common/conf.h"
@@ -3681,8 +3682,7 @@ static void do_final_maps(void)
if( map->list[i].channel )
channel->delete(map->list[i].channel);
- if( map->list[i].qi_data )
- aFree(map->list[i].qi_data);
+ quest->questinfo_vector_clear(i);
HPM->data_store_destroy(&map->list[i].hdata);
}
@@ -3752,11 +3752,7 @@ static void map_flags_init(void)
map->list[i].short_damage_rate = 100;
map->list[i].long_damage_rate = 100;
- if( map->list[i].qi_data )
- aFree(map->list[i].qi_data);
-
- map->list[i].qi_data = NULL;
- map->list[i].qi_count = 0;
+ VECTOR_INIT(map->list[i].qi_data);
}
}
@@ -5455,13 +5451,13 @@ static void map_zone_init(void)
}
}
-static unsigned short map_zone_str2itemid(const char *name)
+static int map_zone_str2itemid(const char *name)
{
struct item_data *data;
if( !name )
return 0;
- if( name[0] == 'I' && name[1] == 'D' && strlen(name) < 8 ) {
+ if (name[0] == 'I' && name[1] == 'D' && strlen(name) <= 12) {
if( !( data = itemdb->exists(atoi(name+2))) ) {
return 0;
}
@@ -5479,7 +5475,7 @@ static unsigned short map_zone_str2skillid(const char *name)
if( !name )
return 0;
- if( name[0] == 'I' && name[1] == 'D' && strlen(name) < 8 ) {
+ if (name[0] == 'I' && name[1] == 'D' && strlen(name) <= 12) {
if( !skill->get_index((nameid = atoi(name+2))) )
return 0;
} else {
@@ -5972,34 +5968,24 @@ static int map_get_new_bonus_id(void)
static void map_add_questinfo(int m, struct questinfo *qi)
{
- unsigned short i;
-
nullpo_retv(qi);
Assert_retv(m >= 0 && m < map->count);
- /* duplicate, override */
- for(i = 0; i < map->list[m].qi_count; i++) {
- if( map->list[m].qi_data[i].nd == qi->nd )
- break;
- }
-
- if( i == map->list[m].qi_count )
- RECREATE(map->list[m].qi_data, struct questinfo, ++map->list[m].qi_count);
- memcpy(&map->list[m].qi_data[i], qi, sizeof(struct questinfo));
+ VECTOR_ENSURE(map->list[m].qi_data, 1, 1);
+ VECTOR_PUSH(map->list[m].qi_data, *qi);
}
static bool map_remove_questinfo(int m, struct npc_data *nd)
{
unsigned short i;
+ nullpo_retr(false, nd);
Assert_retr(false, m >= 0 && m < map->count);
- for(i = 0; i < map->list[m].qi_count; i++) {
- struct questinfo *qi = &map->list[m].qi_data[i];
- if( qi->nd == nd ) {
- memset(&map->list[m].qi_data[i], 0, sizeof(struct questinfo));
- if( i != --map->list[m].qi_count ) {
- memmove(&map->list[m].qi_data[i],&map->list[m].qi_data[i+1],sizeof(struct questinfo)*(map->list[m].qi_count-i));
- }
+
+ for (i = 0; i < VECTOR_LENGTH(map->list[m].qi_data); i++) {
+ struct questinfo *qi_data = &VECTOR_INDEX(map->list[m].qi_data, i);
+ if (qi_data->nd == nd) {
+ VECTOR_ERASE(map->list[m].qi_data, i);
return true;
}
}
@@ -6149,6 +6135,7 @@ int do_final(void)
map->list_final();
vending->final();
rodex->final();
+ achievement->final();
HPM_map_do_final();
@@ -6353,6 +6340,7 @@ static void map_load_defaults(void)
pet_defaults();
path_defaults();
quest_defaults();
+ achievement_defaults();
npc_chat_defaults();
rodex_defaults();
}
@@ -6668,6 +6656,7 @@ int do_init(int argc, char *argv[])
mercenary->init(minimal);
elemental->init(minimal);
quest->init(minimal);
+ achievement->init(minimal);
npc->init(minimal);
unit->init(minimal);
bg->init(minimal);