summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c97
-rw-r--r--src/map/charcommand.c6
-rw-r--r--src/map/clif.c31
-rw-r--r--src/map/guild.c8
-rw-r--r--src/map/guild.h2
-rw-r--r--src/map/map.c22
-rw-r--r--src/map/script.c246
7 files changed, 203 insertions, 209 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index b104633a6..5ec3c1f1b 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -1327,9 +1327,6 @@ int atcommand_rura( const int fd, struct map_session_data* sd, const char* comma
return -1;
}
- if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
- strcat(map_name, ".gat");
-
mapindex = mapindex_name2id(map_name);
if (mapindex)
m = map_mapindex2mapid(mapindex);
@@ -1713,8 +1710,6 @@ int atcommand_whomap3(const int fd, struct map_session_data* sd, const char* com
map_id = sd->bl.m;
else {
sscanf(message, "%15s", map_name);
- if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
- strcat(map_name, ".gat");
if ((map_id = map_mapname2mapid(map_name)) < 0)
map_id = sd->bl.m;
}
@@ -1771,8 +1766,6 @@ int atcommand_whomap2(const int fd, struct map_session_data* sd, const char* com
map_id = sd->bl.m;
else {
sscanf(message, "%15s", map_name);
- if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
- strcat(map_name, ".gat");
if ((map_id = map_mapname2mapid(map_name)) < 0)
map_id = sd->bl.m;
}
@@ -1835,8 +1828,6 @@ int atcommand_whomap(const int fd, struct map_session_data* sd, const char* comm
map_id = sd->bl.m;
else {
sscanf(message, "%15s", map_name);
- if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
- strcat(map_name, ".gat");
if ((map_id = map_mapname2mapid(map_name)) < 0)
map_id = sd->bl.m;
}
@@ -3252,77 +3243,75 @@ int atcommand_go(const int fd, struct map_session_data* sd, const char* command,
clif_displaymessage(fd, " 24=Veins");
return -1;
} else {
- // get possible name of the city and add .gat if not in the name
+ // get possible name of the city
map_name[MAP_NAME_LENGTH-1] = '\0';
for (i = 0; map_name[i]; i++)
map_name[i] = tolower(map_name[i]);
- if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
- strcat(map_name, ".gat");
// try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
- if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
+ if (strncmp(map_name, "prontera", 3) == 0) { // 3 first characters
town = 0;
- } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
+ } else if (strncmp(map_name, "morocc", 3) == 0) { // 3 first characters
town = 1;
- } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
+ } else if (strncmp(map_name, "geffen", 3) == 0) { // 3 first characters
town = 2;
- } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
- strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
+ } else if (strncmp(map_name, "payon", 3) == 0 || // 3 first characters
+ strncmp(map_name, "paion", 3) == 0) { // writing error (3 first characters)
town = 3;
- } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
+ } else if (strncmp(map_name, "alberta", 3) == 0) { // 3 first characters
town = 4;
- } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
- strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
+ } else if (strncmp(map_name, "izlude", 3) == 0 || // 3 first characters
+ strncmp(map_name, "islude", 3) == 0) { // writing error (3 first characters)
town = 5;
- } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
- strcmp(map_name, "al.gat") == 0) { // al (de baran)
+ } else if (strncmp(map_name, "aldebaran", 3) == 0 || // 3 first characters
+ strcmp(map_name, "al") == 0) { // al (de baran)
town = 6;
- } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
- strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
- strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
- strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
+ } else if (strncmp(map_name, "lutie", 3) == 0 || // name of the city, not name of the map (3 first characters)
+ strcmp(map_name, "christmas") == 0 || // name of the symbol
+ strncmp(map_name, "xmas", 3) == 0 || // 3 first characters
+ strncmp(map_name, "x-mas", 3) == 0) { // writing error (3 first characters)
town = 7;
- } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
+ } else if (strncmp(map_name, "comodo", 3) == 0) { // 3 first characters
town = 8;
- } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
+ } else if (strncmp(map_name, "yuno", 3) == 0) { // 3 first characters
town = 9;
- } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
- strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
+ } else if (strncmp(map_name, "amatsu", 3) == 0 || // 3 first characters
+ strncmp(map_name, "ammatsu", 3) == 0) { // writing error (3 first characters)
town = 10;
- } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
+ } else if (strncmp(map_name, "gonryun", 3) == 0) { // 3 first characters
town = 11;
- } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
+ } else if (strncmp(map_name, "umbala", 3) == 0) { // 3 first characters
town = 12;
- } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
+ } else if (strncmp(map_name, "niflheim", 3) == 0) { // 3 first characters
town = 13;
- } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
+ } else if (strncmp(map_name, "louyang", 3) == 0) { // 3 first characters
town = 14;
- } else if (strncmp(map_name, "new_zone01.gat", 3) == 0 || // 3 first characters (or "newbies")
- strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
- strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
+ } else if (strncmp(map_name, "new_zone01", 3) == 0 || // 3 first characters (or "newbies")
+ strncmp(map_name, "startpoint", 3) == 0 || // name of the position (3 first characters)
+ strncmp(map_name, "begining", 3) == 0) { // name of the position (3 first characters)
town = 15;
- } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
- strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
- strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
+ } else if (strncmp(map_name, "sec_pri", 3) == 0 || // 3 first characters
+ strncmp(map_name, "prison", 3) == 0 || // name of the position (3 first characters)
+ strncmp(map_name, "jails", 3) == 0) { // name of the position
town = 16;
- } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
- strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
+ } else if (strncmp(map_name, "jawaii", 3) == 0 || // 3 first characters
+ strncmp(map_name, "jawai", 3) == 0) { // writing error (3 first characters)
town = 17;
- } else if (strncmp(map_name, "ayothaya.gat", 2) == 0 || // 2 first characters
- strncmp(map_name, "ayotaya.gat", 2) == 0) { // writing error (2 first characters)
+ } else if (strncmp(map_name, "ayothaya", 2) == 0 || // 2 first characters
+ strncmp(map_name, "ayotaya", 2) == 0) { // writing error (2 first characters)
town = 18;
- } else if (strncmp(map_name, "einbroch.gat", 5) == 0 || // 5 first characters
- strncmp(map_name, "ainbroch.gat", 5) == 0) { // writing error (5 first characters)
+ } else if (strncmp(map_name, "einbroch", 5) == 0 || // 5 first characters
+ strncmp(map_name, "ainbroch", 5) == 0) { // writing error (5 first characters)
town = 19;
- } else if (strncmp(map_name, "lighthalzen.gat", 3) == 0 || // 3 first characters
- strncmp(map_name, "reichthalzen.gat", 3) == 0) { // 'alternative' name (3 first characters)
+ } else if (strncmp(map_name, "lighthalzen", 3) == 0 || // 3 first characters
+ strncmp(map_name, "reichthalzen", 3) == 0) { // 'alternative' name (3 first characters)
town = 20;
- } else if (strncmp(map_name, "einbech.gat", 3) == 0) { // 3 first characters
+ } else if (strncmp(map_name, "einbech", 3) == 0) { // 3 first characters
town = 21;
- } else if (strncmp(map_name, "hugel.gat", 3) == 0) { // 3 first characters
+ } else if (strncmp(map_name, "hugel", 3) == 0) { // 3 first characters
town = 22;
- } else if (strncmp(map_name, "rachel.gat", 3) == 0) { // 3 first characters
+ } else if (strncmp(map_name, "rachel", 3) == 0) { // 3 first characters
town = 23;
- } else if (strncmp(map_name, "veins.gat", 3) == 0) { // 3 first characters
+ } else if (strncmp(map_name, "veins", 3) == 0) { // 3 first characters
town = 24;
}
@@ -3650,8 +3639,6 @@ void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const
if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
map_id = sd->bl.m;
else {
- if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
- strcat(map_name, ".gat");
if ((map_id = map_mapname2mapid(map_name)) < 0)
map_id = sd->bl.m;
}
@@ -5446,8 +5433,6 @@ int atcommand_mapinfo(const int fd, struct map_session_data* sd, const char* com
atcmd_player_name[MAP_NAME_LENGTH] = '\0';
m_id = map_mapindex2mapid(sd->mapindex);
} else {
- if (strstr(atcmd_player_name, ".gat") == NULL && strstr(atcmd_player_name, ".afm") == NULL && strlen(atcmd_player_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
- strcat(atcmd_player_name, ".gat");
m_id = map_mapname2mapid(atcmd_player_name);
}
if (m_id < 0) {
diff --git a/src/map/charcommand.c b/src/map/charcommand.c
index 5eb03dd1f..743f456f6 100644
--- a/src/map/charcommand.c
+++ b/src/map/charcommand.c
@@ -628,9 +628,6 @@ int charcommand_save(
return -1;
}
- if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
- strcat(map_name, ".gat");
-
if ((pl_sd = map_nick2sd(character)) != NULL) {
if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change save point only to lower or same gm level
m = map_mapname2mapid(map_name);
@@ -1146,9 +1143,6 @@ int charcommand_warp(
return -1;
}
- if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
- strcat(map_name, ".gat");
-
if ((pl_sd = map_nick2sd(character)) == NULL) {
clif_displaymessage(fd, msg_table[3]); // Character not found.
return -1;
diff --git a/src/map/clif.c b/src/map/clif.c
index bcfae2bf2..f5dff2f85 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -1596,14 +1596,17 @@ void clif_setwaitclose(int fd) {
*/
int clif_changemap(struct map_session_data *sd, short map, int x, int y) {
int fd;
+ char map_name[MAP_NAME_LENGTH];
nullpo_retr(0, sd);
fd = sd->fd;
-
+
+ snprintf(map_name, MAP_NAME_LENGTH, "%s.gat", mapindex_id2name(map));
+
WFIFOHEAD(fd, packet_len(0x91));
WFIFOW(fd,0) = 0x91;
- memcpy(WFIFOP(fd,2), mapindex_id2name(map), MAP_NAME_LENGTH);
+ memcpy(WFIFOP(fd,2), map_name, MAP_NAME_LENGTH);
WFIFOW(fd,18) = x;
WFIFOW(fd,20) = y;
WFIFOSET(fd, packet_len(0x91));
@@ -5616,12 +5619,17 @@ int clif_party_created(struct map_session_data *sd,int flag)
int clif_party_member_info(struct party_data *p, struct map_session_data *sd)
{
unsigned char buf[96];
+ char map_name[MAP_NAME_LENGTH];
+
if (!sd) { //Pick any party member (this call is used when changing item share rules)
int i;
for (i=0; i<MAX_PARTY && !p->data[i].sd; i++);
if (i >= MAX_PARTY) return 0; //Should never happen...
sd = p->data[i].sd;
}
+
+ snprintf(map_name, MAP_NAME_LENGTH, "%s.gat", mapindex_id2name(sd->mapindex));
+
WBUFW(buf,0)=0x1e9;
WBUFL(buf,2)= sd->status.account_id;
WBUFL(buf,6)= 0; //Apparently setting this to 1 makes you adoptable.
@@ -5630,7 +5638,7 @@ int clif_party_member_info(struct party_data *p, struct map_session_data *sd)
WBUFB(buf,14)=0; //Unconfirmed byte, could be online/offline.
memcpy(WBUFP(buf,15), p->party.name, NAME_LENGTH);
memcpy(WBUFP(buf,39), sd->status.name, NAME_LENGTH);
- memcpy(WBUFP(buf,63), mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
+ memcpy(WBUFP(buf,63), map_name, MAP_NAME_LENGTH);
WBUFB(buf,79) = (p->party.item&1)?1:0;
WBUFB(buf,80) = (p->party.item&2)?1:0;
clif_send(buf,packet_len(0x1e9),&sd->bl,PARTY);
@@ -5655,13 +5663,17 @@ int clif_party_info(struct party_data* p, struct map_session_data *sd)
for(i = 0, c = 0; i < MAX_PARTY; i++)
{
struct party_member* m = &p->party.member[i];
+ char map_name[MAP_NAME_LENGTH];
+
if(!m->account_id) continue;
if(party_sd == NULL) party_sd = p->data[i].sd;
+ snprintf(map_name, MAP_NAME_LENGTH, "%s.gat", mapindex_id2name(m->map));
+
WBUFL(buf,28+c*46) = m->account_id;
memcpy(WBUFP(buf,28+c*46+4), m->name, NAME_LENGTH);
- memcpy(WBUFP(buf,28+c*46+28), mapindex_id2name(m->map), MAP_NAME_LENGTH);
+ memcpy(WBUFP(buf,28+c*46+28), map_name, MAP_NAME_LENGTH);
WBUFB(buf,28+c*46+44) = (m->leader) ? 0 : 1;
WBUFB(buf,28+c*46+45) = (m->online) ? 0 : 1;
c++;
@@ -5940,10 +5952,13 @@ int clif_hpmeter(struct map_session_data *sd)
int clif_party_move(struct party *p,struct map_session_data *sd,int online)
{
unsigned char buf[128];
+ char map_name[MAP_NAME_LENGTH];
nullpo_retr(0, sd);
nullpo_retr(0, p);
+ snprintf(map_name, MAP_NAME_LENGTH, "%s.gat", map[sd->bl.m].name);
+
WBUFW(buf, 0)=0x104;
WBUFL(buf, 2)=sd->status.account_id;
WBUFL(buf, 6)=0;
@@ -5952,7 +5967,7 @@ int clif_party_move(struct party *p,struct map_session_data *sd,int online)
WBUFB(buf,14)=!online;
memcpy(WBUFP(buf,15),p->name, NAME_LENGTH);
memcpy(WBUFP(buf,39),sd->status.name, NAME_LENGTH);
- memcpy(WBUFP(buf,63),map[sd->bl.m].name, MAP_NAME_LENGTH);
+ memcpy(WBUFP(buf,63),map_name, MAP_NAME_LENGTH);
clif_send(buf,packet_len(0x104),&sd->bl,PARTY);
return 0;
}
@@ -7794,9 +7809,13 @@ void clif_gospel_info(struct map_session_data *sd, int type)
void clif_feel_info(struct map_session_data *sd, unsigned char feel_level, unsigned char type)
{
int fd=sd->fd;
+ char map_name[MAP_NAME_LENGTH];
+
+ snprintf(map_name, MAP_NAME_LENGTH, "%s.gat", mapindex_id2name(sd->feel_map[feel_level].index));
+
WFIFOHEAD(fd,packet_len(0x20e));
WFIFOW(fd,0)=0x20e;
- memcpy(WFIFOP(fd,2),mapindex_id2name(sd->feel_map[feel_level].index), MAP_NAME_LENGTH);
+ memcpy(WFIFOP(fd,2),map_name, MAP_NAME_LENGTH);
WFIFOL(fd,26)=sd->bl.id;
WFIFOB(fd,30)=feel_level;
WFIFOB(fd,31)=type?1:0;
diff --git a/src/map/guild.c b/src/map/guild.c
index c53343703..64af2e12a 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -253,6 +253,9 @@ struct guild_castle *guild_mapname2gc(char *mapname)
{
int i;
struct guild_castle *gc=NULL;
+
+ map_normalize_name(mapname);
+
for(i=0;i<MAX_GUILDCASTLE;i++){
gc=guild_castle_search(i);
if(!gc) continue;
@@ -261,14 +264,15 @@ struct guild_castle *guild_mapname2gc(char *mapname)
return NULL;
}
-struct guild_castle *guild_mapindex2gc(short mapname)
+struct guild_castle *guild_mapindex2gc(short mapindex)
{
int i;
struct guild_castle *gc=NULL;
+
for(i=0;i<MAX_GUILDCASTLE;i++){
gc=guild_castle_search(i);
if(!gc) continue;
- if(strcmp(gc->map_name,mapindex_id2name(mapname))==0) return gc;
+ if(strcmp(gc->map_name,mapindex_id2name(mapindex))==0) return gc;
}
return NULL;
}
diff --git a/src/map/guild.h b/src/map/guild.h
index d5b501e3a..9f21cd550 100644
--- a/src/map/guild.h
+++ b/src/map/guild.h
@@ -25,7 +25,7 @@ struct guild *guild_searchname(char *str);
struct guild_castle *guild_castle_search(int gcid);
struct guild_castle *guild_mapname2gc(char *mapname);
-struct guild_castle *guild_mapindex2gc(short mapname);
+struct guild_castle *guild_mapindex2gc(short mapindex);
struct map_session_data *guild_getavailablesd(struct guild *g);
int guild_getindex(struct guild *g,int account_id,int char_id);
diff --git a/src/map/map.c b/src/map/map.c
index 3f37c430e..dfdda95b7 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -2432,12 +2432,6 @@ int map_eraseipport(unsigned short mapindex,unsigned long ip,int port)
* Map cache reading
*===========================================*/
-// This is the main header found at the very beginning of the file
-/*struct map_cache_head {
- long filesize;
- unsigned short map_count;
-};*/
-
// This is the header appended before every compressed map cells info
struct map_cache_info {
char name[MAP_NAME_LENGTH];
@@ -2449,6 +2443,7 @@ struct map_cache_info {
FILE *map_cache_fp;
+// Removes the extension from a map name
char *map_normalize_name(char *mapname)
{
char *ptr, *ptr2;
@@ -2457,7 +2452,8 @@ char *map_normalize_name(char *mapname)
while (ptr[1] && (ptr2 = strchr(ptr+1, '.')))
ptr = ptr2; //Skip to the last dot.
if(stricmp(ptr,".gat") == 0 ||
- stricmp(ptr,".afm") == 0)
+ stricmp(ptr,".afm") == 0 ||
+ stricmp(ptr,".af2") == 0)
*ptr = '\0'; //Remove extension.
}
return mapname;
@@ -2471,6 +2467,9 @@ int map_readmap(struct map_data *m)
unsigned long size;
unsigned char *buf;
+ if(!map_cache_fp)
+ return 0;
+
fseek(map_cache_fp, 0, SEEK_SET);
fread(&map_count, sizeof(map_count), 1, map_cache_fp);
@@ -2628,6 +2627,7 @@ int map_readallmaps (void)
map[i].block_count = (int*)aCallocA(size, 1);
map[i].block_mob_count = (int*)aCallocA(size, 1);
+ mapindex_addmap(map[i].index, map[i].name);
uidb_put(map_db, (unsigned int)map[i].index, &map[i]);
}
@@ -3177,8 +3177,6 @@ void do_final(void) {
if (map[i].moblist[j]) aFree(map[i].moblist[j]);
}
}
-
- mapindex_final();
id_db->destroy(id_db, NULL);
pc_db->destroy(pc_db, NULL);
@@ -3337,9 +3335,6 @@ int do_init(int argc, char *argv[]) {
charsql_db_init(1); //Connecting to chardb
#endif /* not TXT_ONLY */
- mapindex_init();
- grfio_init(GRF_PATH_FILENAME);
-
map_readallmaps();
add_timer_func_list(map_freeblock_timer, "map_freeblock_timer");
@@ -3378,9 +3373,6 @@ int do_init(int argc, char *argv[]) {
npc_event_do_oninit(); // npcのOnInitイベント?行
- //Done loading with the maps, no need for the grf module anymore.
- grfio_final();
-
if( console )
{
//##TODO invoke a CONSOLE_START plugin event
diff --git a/src/map/script.c b/src/map/script.c
index 11f5c6dda..6f862400f 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -4593,7 +4593,7 @@ BUILDIN_FUNC(areawarp)
* warpchar [LuzZza]
* Useful for warp one player from
* another player npc-session.
- * Using: warpchar "mapname.gat",x,y,Char_ID;
+ * Using: warpchar "mapname",x,y,Char_ID;
*------------------------------------------
*/
BUILDIN_FUNC(warpchar)
@@ -4631,7 +4631,7 @@ BUILDIN_FUNC(warpchar)
/*==========================================
* Warpparty - [Fredzilla]
- * Syntax: warpparty "mapname.gat",x,y,Party_ID;
+ * Syntax: warpparty "mapname",x,y,Party_ID;
*------------------------------------------
*/
BUILDIN_FUNC(warpparty)
@@ -4714,7 +4714,7 @@ BUILDIN_FUNC(warpparty)
}
/*==========================================
* Warpguild - [Fredzilla]
- * Syntax: warpguild "mapname.gat",x,y,Guild_ID;
+ * Syntax: warpguild "mapname",x,y,Guild_ID;
*------------------------------------------
*/
BUILDIN_FUNC(warpguild)
@@ -7806,7 +7806,7 @@ BUILDIN_FUNC(getusersname)
return 0;
}
/*==========================================
- * getmapguildusers("mapname.gat",guild ID) Returns the number guild members present on a map [Reddozen]
+ * getmapguildusers("mapname",guild ID) Returns the number guild members present on a map [Reddozen]
*------------------------------------------
*/
BUILDIN_FUNC(getmapguildusers)
@@ -9132,16 +9132,12 @@ BUILDIN_FUNC(flagemblem)
BUILDIN_FUNC(getcastlename)
{
- const char *mapname=conv_str(st,& (st->stack->stack_data[st->start+2]));
- struct guild_castle *gc=NULL;
- int i;
- for(i=0;i<MAX_GUILDCASTLE;i++){
- if( (gc=guild_castle_search(i)) != NULL ){
- if(strcmp(mapname,gc->map_name)==0){
- break;
- }
- }
- }
+ char mapname[MAP_NAME_LENGTH];
+ struct guild_castle *gc;
+
+ strncpy(mapname, conv_str(st,script_getdata(st,2)), MAP_NAME_LENGTH);
+ gc = guild_mapname2gc(mapname);
+
if(gc)
push_str(st->stack,C_CONSTSTR,gc->castle_name);
else
@@ -9151,66 +9147,67 @@ BUILDIN_FUNC(getcastlename)
BUILDIN_FUNC(getcastledata)
{
- char mapname[MAP_NAME_LENGTH+1];
+ char mapname[MAP_NAME_LENGTH];
int index=conv_num(st,& (st->stack->stack_data[st->start+3]));
const char *event=NULL;
struct guild_castle *gc;
- int i,j;
+ int i;
strncpy(mapname, conv_str(st,script_getdata(st,2)), MAP_NAME_LENGTH);
- mapname[MAP_NAME_LENGTH] = '\0';
- map_normalize_name(mapname);
-
- if( st->end>st->start+4 && index==0){
- for(i=0,j=-1;i<MAX_GUILDCASTLE;i++)
- if( (gc=guild_castle_search(i)) != NULL &&
- strcmp(mapname,gc->map_name)==0 )
- j=i;
- if(j>=0){
- event=conv_str(st,& (st->stack->stack_data[st->start+4]));
- check_event(st, event);
- guild_addcastleinfoevent(j,17,event);
- }
- }
-
- for(i=0;i<MAX_GUILDCASTLE;i++){
- if( (gc=guild_castle_search(i)) != NULL ){
- if(strcmp(mapname,gc->map_name)==0){
- switch(index){
- case 0: for(j=1;j<26;j++) guild_castledataload(gc->castle_id,j); break; // Initialize[AgitInit]
- case 1: push_val(st->stack,C_INT,gc->guild_id); break;
- case 2: push_val(st->stack,C_INT,gc->economy); break;
- case 3: push_val(st->stack,C_INT,gc->defense); break;
- case 4: push_val(st->stack,C_INT,gc->triggerE); break;
- case 5: push_val(st->stack,C_INT,gc->triggerD); break;
- case 6: push_val(st->stack,C_INT,gc->nextTime); break;
- case 7: push_val(st->stack,C_INT,gc->payTime); break;
- case 8: push_val(st->stack,C_INT,gc->createTime); break;
- case 9: push_val(st->stack,C_INT,gc->visibleC); break;
- case 10:
- case 11:
- case 12:
- case 13:
- case 14:
- case 15:
- case 16:
- case 17:
- push_val(st->stack,C_INT,gc->guardian[index-10].visible); break;
- case 18:
- case 19:
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- push_val(st->stack,C_INT,gc->guardian[index-18].hp); break;
- default:
- push_val(st->stack,C_INT,0); break;
- }
- return 0;
- }
+ gc = guild_mapname2gc(mapname);
+
+ if(st->end>st->start+4 && index==0 && gc) {
+ event=conv_str(st,& (st->stack->stack_data[st->start+4]));
+ check_event(st, event);
+ guild_addcastleinfoevent(gc->castle_id,17,event);
+ }
+
+ if(gc){
+ switch(index){
+ case 0:
+ for(i=1;i<26;i++) // Initialize[AgitInit]
+ guild_castledataload(gc->castle_id,i);
+ break;
+ case 1:
+ push_val(st->stack,C_INT,gc->guild_id); break;
+ case 2:
+ push_val(st->stack,C_INT,gc->economy); break;
+ case 3:
+ push_val(st->stack,C_INT,gc->defense); break;
+ case 4:
+ push_val(st->stack,C_INT,gc->triggerE); break;
+ case 5:
+ push_val(st->stack,C_INT,gc->triggerD); break;
+ case 6:
+ push_val(st->stack,C_INT,gc->nextTime); break;
+ case 7:
+ push_val(st->stack,C_INT,gc->payTime); break;
+ case 8:
+ push_val(st->stack,C_INT,gc->createTime); break;
+ case 9:
+ push_val(st->stack,C_INT,gc->visibleC); break;
+ case 10:
+ case 11:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ push_val(st->stack,C_INT,gc->guardian[index-10].visible); break;
+ case 18:
+ case 19:
+ case 20:
+ case 21:
+ case 22:
+ case 23:
+ case 24:
+ case 25:
+ push_val(st->stack,C_INT,gc->guardian[index-18].hp); break;
+ default:
+ push_val(st->stack,C_INT,0); break;
}
+ return 0;
}
push_val(st->stack,C_INT,0);
return 0;
@@ -9218,69 +9215,72 @@ BUILDIN_FUNC(getcastledata)
BUILDIN_FUNC(setcastledata)
{
- char mapname[MAP_NAME_LENGTH+1];
+ char mapname[MAP_NAME_LENGTH];
int index=conv_num(st,& (st->stack->stack_data[st->start+3]));
int value=conv_num(st,& (st->stack->stack_data[st->start+4]));
struct guild_castle *gc;
- int i;
strncpy(mapname, conv_str(st,script_getdata(st,2)), MAP_NAME_LENGTH);
- mapname[MAP_NAME_LENGTH] = '\0';
- map_normalize_name(mapname);
-
- for(i=0;i<MAX_GUILDCASTLE;i++){
- if( (gc=guild_castle_search(i)) != NULL ){
- if(strcmp(mapname,gc->map_name)==0){
- // Save Data byself First
- switch(index){
- case 1: gc->guild_id = value; break;
- case 2: gc->economy = value; break;
- case 3: gc->defense = value; break;
- case 4: gc->triggerE = value; break;
- case 5: gc->triggerD = value; break;
- case 6: gc->nextTime = value; break;
- case 7: gc->payTime = value; break;
- case 8: gc->createTime = value; break;
- case 9: gc->visibleC = value; break;
- case 10:
- case 11:
- case 12:
- case 13:
- case 14:
- case 15:
- case 16:
- case 17:
- gc->guardian[index-10].visible = value; break;
- case 18:
- case 19:
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- gc->guardian[index-18].hp = value;
- if (gc->guardian[index-18].id)
- { //Update this mob's HP.
- struct block_list *bl = map_id2bl(gc->guardian[index-18].id);
- if (!bl)
- { //Wrong target?
- gc->guardian[index-18].id = 0;
- break;
- }
- if (value < 1) {
- status_kill(bl);
- break;
- }
- status_set_hp(bl, value, 0);
+ gc = guild_mapname2gc(mapname);
+
+ if(gc) {
+ // Save Data byself First
+ switch(index){
+ case 1:
+ gc->guild_id = value; break;
+ case 2:
+ gc->economy = value; break;
+ case 3:
+ gc->defense = value; break;
+ case 4:
+ gc->triggerE = value; break;
+ case 5:
+ gc->triggerD = value; break;
+ case 6:
+ gc->nextTime = value; break;
+ case 7:
+ gc->payTime = value; break;
+ case 8:
+ gc->createTime = value; break;
+ case 9:
+ gc->visibleC = value; break;
+ case 10:
+ case 11:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ gc->guardian[index-10].visible = value; break;
+ case 18:
+ case 19:
+ case 20:
+ case 21:
+ case 22:
+ case 23:
+ case 24:
+ case 25:
+ gc->guardian[index-18].hp = value;
+ if (gc->guardian[index-18].id)
+ { //Update this mob's HP.
+ struct block_list *bl = map_id2bl(gc->guardian[index-18].id);
+ if (!bl)
+ { //Wrong target?
+ gc->guardian[index-18].id = 0;
+ break;
}
- break;
- default: return 0;
+ if (value < 1) {
+ status_kill(bl);
+ break;
+ }
+ status_set_hp(bl, value, 0);
}
- guild_castledatasave(gc->castle_id,index,value);
+ break;
+ default:
return 0;
- }
}
+ guild_castledatasave(gc->castle_id,index,value);
}
return 0;
}
@@ -10853,7 +10853,7 @@ BUILDIN_FUNC(prompt)
/*==========================================
* GetMapMobs
returns mob counts on a set map:
- e.g. GetMapMobs("prontera.gat")
+ e.g. GetMapMobs("prontera")
use "this" - for player's map
*------------------------------------------
*/