summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/char/char.c24
-rw-r--r--src/char_sql/char.c4
-rw-r--r--src/common/grfio.c874
-rw-r--r--src/common/mapindex.c24
-rw-r--r--src/common/mapindex.h51
-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
-rw-r--r--src/tool/mapcache.c7
13 files changed, 255 insertions, 1141 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 54fa75c68..5a29a1344 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -3539,11 +3539,15 @@ int parse_char(int fd) {
ShowWarning("Unable to find map-server for '%s', sending to major city '%s'.\n", mapindex_id2name(cd->last_point.map), mapindex_id2name(j));
cd->last_point.map = j;
}
- { //Send player to map
+ {
+ //Send player to map
+ char map_name[MAP_NAME_LENGTH];
+ snprintf(map_name, MAP_NAME_LENGTH, "%s.gat", mapindex_id2name(cd->last_point.map));
+
WFIFOHEAD(fd, 28);
WFIFOW(fd,0) = 0x71;
WFIFOL(fd,2) = cd->char_id;
- memcpy(WFIFOP(fd,6), mapindex_id2name(cd->last_point.map), MAP_NAME_LENGTH);
+ memcpy(WFIFOP(fd,6), map_name, MAP_NAME_LENGTH);
// Advanced subnet check [LuzZza]
if((subnet_map_ip = lan_subnetcheck((long *)p)))
@@ -4170,15 +4174,13 @@ int char_config_read(const char *cfgName) {
int x, y;
if (sscanf(w2, "%[^,],%d,%d", map, &x, &y) < 3)
continue;
- if (strstr(map, ".gat") != NULL) { // Verify at least if '.gat' is in the map name
- start_point.map = mapindex_name2id(map);
- if (!start_point.map) {
- ShowError("Specified start_point %s not found in map-index cache.\n", map);
- start_point.map = 0;
- }
- start_point.x = x;
- start_point.y = y;
+ start_point.map = mapindex_name2id(map);
+ if (!start_point.map) {
+ ShowError("Specified start_point %s not found in map-index cache.\n", map);
+ start_point.map = 0;
}
+ start_point.x = x;
+ start_point.y = y;
} else if(strcmpi(w1,"log_char")==0) { //log char or not [devil]
log_char = atoi(w2);
} else if (strcmpi(w1, "start_zeny") == 0) {
@@ -4318,7 +4320,7 @@ int do_init(int argc, char **argv) {
int i;
mapindex_init(); //Needed here for the start-point reading.
- start_point.map = mapindex_name2id("new_zone01.gat");
+ start_point.map = mapindex_name2id("new_zone01");
char_config_read((argc < 2) ? CHAR_CONF_NAME : argv[1]);
char_lan_config_read((argc > 3) ? argv[3] : LOGIN_LAN_CONF_NAME);
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index de0b79bd1..0afaa526a 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -3359,10 +3359,12 @@ int parse_char(int fd) {
char_dat.last_point.map = j;
}
{ //Send player to map.
+ char map_name[MAP_NAME_LENGTH];
+ snprintf(map_name, MAP_NAME_LENGTH, "%s.gat", mapindex_id2name(char_dat.last_point.map));
WFIFOHEAD(fd,28);
WFIFOW(fd, 0) =0x71;
WFIFOL(fd, 2) =char_dat.char_id;
- memcpy(WFIFOP(fd,6), mapindex_id2name(char_dat.last_point.map), MAP_NAME_LENGTH);
+ memcpy(WFIFOP(fd,6), map_name, MAP_NAME_LENGTH);
// Advanced subnet check [LuzZza]
if((subnet_map_ip = lan_subnetcheck((long *)p)))
diff --git a/src/common/grfio.c b/src/common/grfio.c
index ba3b55bb3..a2d7f7f5a 100644
--- a/src/common/grfio.c
+++ b/src/common/grfio.c
@@ -1,28 +1,6 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
-/*********************************************************************
- *
- * Ragnarok Online Emulator : grfio.c -- grf file I/O Module
- *--------------------------------------------------------------------
- * special need library : zlib
- *********************************************************************
- * $Id: grfio.c,v 1.2 2004/09/29 17:31:49 kalaspuff Exp $
- *
- * 2002/12/18... the original edition
- * 2003/01/23 ... Code correction
- * 2003/02/01 ... An addition and decryption processing are improved for LocalFile and two or more GRF(s) check processing.
- * 2003/02/02 ... Even if there is no grf it does not stop -- as -- correction
- * 2003/02/02... grf reading specification can be added later -- as -- correction (grfio_add function addition)
- * 2003/02 / 03... at the time of grfio_resourcecheck processing the entry addition processing method -- correction
- * 2003/02/05... change of the processing in grfio_init
- * 2003/02/23... a local file check -- GRFIO_LOCAL -- switch (Defoe -- Function Off)
- * 2003/10/21 ... The data of alpha client was read.
- * 2003/11/10 ... Ready new grf format.
- * 2003/11/11 ... version check fix & bug fix
- * 2006/04/16 ... fixed crash grfio_find_file when file is not found.
- */
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -30,13 +8,9 @@
#include <sys/stat.h>
#include "grfio.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/malloc.h"
+#include "malloc.h"
#include "../zlib/unzip.h"
-#define CHUNK 16384
-
#ifdef __WIN32
#include "../zlib/zlib.h"
#include "../zlib/iowin32.h"
@@ -46,225 +20,6 @@
#endif
#endif
-typedef unsigned char BYTE;
-typedef unsigned short WORD;
-typedef unsigned long DWORD;
-
-//static char data_file[1024] = ""; // "data.grf";
-//static char sdata_file[1024] = ""; // "sdata.grf";
-//static char adata_file[1024] = ""; // "adata.grf";
-static char data_dir[1024] = ""; // "../";
-
-//----------------------------
-// file entry table struct
-//----------------------------
-typedef struct {
- int srclen; // compressed size
- int srclen_aligned; //
- int declen; // original size
- int srcpos;
- short next;
- int cycle;
- char type;
- char fn[128-4*5]; // file name
- char *fnd;
- signed char gentry; // read grf file select
-} FILELIST;
-//gentry ... 0 : It acquires from a local file.
-// It acquires from the resource file of 1>=:gentry_table[gentry-1].
-// 1<=: Check a local file.
-// If it is, after re-setting to 0, it acquires from a local file.
-// If there is nothing, mark reversal will be carried out, and it will re-set, and will acquire from a resource file as well as 1>=.
-
-//Since char defines *FILELIST.gentry, the maximum which can be added by grfio_add becomes by 127 pieces.
-
-#define GENTRY_LIMIT 512
-#define FILELIST_LIMIT 1048576 // temporary maximum, and a theory top maximum are 2G.
-
-static FILELIST *filelist = NULL;
-static int filelist_entrys = 0;
-static int filelist_maxentry = 0;
-
-static char **gentry_table = NULL;
-static int gentry_entrys = 0;
-static int gentry_maxentry = 0;
-
-//----------------------------
-// file list hash table
-//----------------------------
-static int filelist_hash[256];
-
-//----------------------------
-// grf decode data table
-//----------------------------
-static unsigned char BitMaskTable[8] = {
- 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01
-};
-
-static char BitSwapTable1[64] = {
- 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4,
- 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8,
- 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3,
- 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7
-};
-static char BitSwapTable2[64] = {
- 40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15, 55, 23, 63, 31,
- 38, 6, 46, 14, 54, 22, 62, 30, 37, 5, 45, 13, 53, 21, 61, 29,
- 36, 4, 44, 12, 52, 20, 60, 28, 35, 3, 43, 11, 51, 19, 59, 27,
- 34, 2, 42, 10, 50, 18, 58, 26, 33, 1, 41, 9, 49, 17, 57, 25
-};
-static char BitSwapTable3[32] = {
- 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10,
- 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25
-};
-
-static unsigned char NibbleData[4][64]={
- {
- 0xef, 0x03, 0x41, 0xfd, 0xd8, 0x74, 0x1e, 0x47, 0x26, 0xef, 0xfb, 0x22, 0xb3, 0xd8, 0x84, 0x1e,
- 0x39, 0xac, 0xa7, 0x60, 0x62, 0xc1, 0xcd, 0xba, 0x5c, 0x96, 0x90, 0x59, 0x05, 0x3b, 0x7a, 0x85,
- 0x40, 0xfd, 0x1e, 0xc8, 0xe7, 0x8a, 0x8b, 0x21, 0xda, 0x43, 0x64, 0x9f, 0x2d, 0x14, 0xb1, 0x72,
- 0xf5, 0x5b, 0xc8, 0xb6, 0x9c, 0x37, 0x76, 0xec, 0x39, 0xa0, 0xa3, 0x05, 0x52, 0x6e, 0x0f, 0xd9,
- }, {
- 0xa7, 0xdd, 0x0d, 0x78, 0x9e, 0x0b, 0xe3, 0x95, 0x60, 0x36, 0x36, 0x4f, 0xf9, 0x60, 0x5a, 0xa3,
- 0x11, 0x24, 0xd2, 0x87, 0xc8, 0x52, 0x75, 0xec, 0xbb, 0xc1, 0x4c, 0xba, 0x24, 0xfe, 0x8f, 0x19,
- 0xda, 0x13, 0x66, 0xaf, 0x49, 0xd0, 0x90, 0x06, 0x8c, 0x6a, 0xfb, 0x91, 0x37, 0x8d, 0x0d, 0x78,
- 0xbf, 0x49, 0x11, 0xf4, 0x23, 0xe5, 0xce, 0x3b, 0x55, 0xbc, 0xa2, 0x57, 0xe8, 0x22, 0x74, 0xce,
- }, {
- 0x2c, 0xea, 0xc1, 0xbf, 0x4a, 0x24, 0x1f, 0xc2, 0x79, 0x47, 0xa2, 0x7c, 0xb6, 0xd9, 0x68, 0x15,
- 0x80, 0x56, 0x5d, 0x01, 0x33, 0xfd, 0xf4, 0xae, 0xde, 0x30, 0x07, 0x9b, 0xe5, 0x83, 0x9b, 0x68,
- 0x49, 0xb4, 0x2e, 0x83, 0x1f, 0xc2, 0xb5, 0x7c, 0xa2, 0x19, 0xd8, 0xe5, 0x7c, 0x2f, 0x83, 0xda,
- 0xf7, 0x6b, 0x90, 0xfe, 0xc4, 0x01, 0x5a, 0x97, 0x61, 0xa6, 0x3d, 0x40, 0x0b, 0x58, 0xe6, 0x3d,
- }, {
- 0x4d, 0xd1, 0xb2, 0x0f, 0x28, 0xbd, 0xe4, 0x78, 0xf6, 0x4a, 0x0f, 0x93, 0x8b, 0x17, 0xd1, 0xa4,
- 0x3a, 0xec, 0xc9, 0x35, 0x93, 0x56, 0x7e, 0xcb, 0x55, 0x20, 0xa0, 0xfe, 0x6c, 0x89, 0x17, 0x62,
- 0x17, 0x62, 0x4b, 0xb1, 0xb4, 0xde, 0xd1, 0x87, 0xc9, 0x14, 0x3c, 0x4a, 0x7e, 0xa8, 0xe2, 0x7d,
- 0xa0, 0x9f, 0xf6, 0x5c, 0x6a, 0x09, 0x8d, 0xf0, 0x0f, 0xe3, 0x53, 0x25, 0x95, 0x36, 0x28, 0xcb,
- }
-};
-/*-----------------
- * long data get
- */
-static unsigned int getlong(unsigned char *p)
-{
-// return *p+p[1]*256+(p[2]+p[3]*256)*65536;
- return p[0]
- | p[1] << 0x08
- | p[2] << 0x10
- | p[3] << 0x18; // Shinomori
-}
-
-/*==========================================
- * Grf data decode : Subs
- *------------------------------------------
- */
-static void NibbleSwap(BYTE *Src, int len)
-{
- for(;0<len;len--,Src++) {
- *Src = (*Src>>4) | (*Src<<4);
- }
-}
-
-static void BitConvert(BYTE *Src,char *BitSwapTable)
-{
- int lop,prm;
- BYTE tmp[8];
-// *(DWORD*)tmp=*(DWORD*)(tmp+4)=0;
- memset(tmp,0,8);
- for(lop=0;lop!=64;lop++) {
- prm = BitSwapTable[lop]-1;
- if (Src[(prm >> 3) & 7] & BitMaskTable[prm & 7]) {
- tmp[(lop >> 3) & 7] |= BitMaskTable[lop & 7];
- }
- }
-// *(DWORD*)Src = *(DWORD*)tmp;
-// *(DWORD*)(Src+4) = *(DWORD*)(tmp+4);
- memcpy(Src,tmp,8);
-}
-
-static void BitConvert4(BYTE *Src)
-{
- int lop,prm;
- BYTE tmp[8];
- tmp[0] = ((Src[7]<<5) | (Src[4]>>3)) & 0x3f; // ..0 vutsr
- tmp[1] = ((Src[4]<<1) | (Src[5]>>7)) & 0x3f; // ..srqpo n
- tmp[2] = ((Src[4]<<5) | (Src[5]>>3)) & 0x3f; // ..o nmlkj
- tmp[3] = ((Src[5]<<1) | (Src[6]>>7)) & 0x3f; // ..kjihg f
- tmp[4] = ((Src[5]<<5) | (Src[6]>>3)) & 0x3f; // ..g fedcb
- tmp[5] = ((Src[6]<<1) | (Src[7]>>7)) & 0x3f; // ..cba98 7
- tmp[6] = ((Src[6]<<5) | (Src[7]>>3)) & 0x3f; // ..8 76543
- tmp[7] = ((Src[7]<<1) | (Src[4]>>7)) & 0x3f; // ..43210 v
-
- for(lop=0;lop!=4;lop++) {
- tmp[lop] = (NibbleData[lop][tmp[lop*2]] & 0xf0)
- | (NibbleData[lop][tmp[lop*2+1]] & 0x0f);
- }
-
- *(DWORD*)(tmp+4)=0;
- for(lop=0;lop!=32;lop++) {
- prm = BitSwapTable3[lop]-1;
- if (tmp[prm >> 3] & BitMaskTable[prm & 7]) {
- tmp[(lop >> 3) + 4] |= BitMaskTable[lop & 7];
- }
- }
-// *(DWORD*)Src ^= *(DWORD*)(tmp+4);
- Src[0] ^= tmp[4];
- Src[1] ^= tmp[5];
- Src[2] ^= tmp[6];
- Src[3] ^= tmp[7];
-}
-
-static void decode_des_etc(BYTE *buf,int len,int type,int cycle)
-{
- int lop,cnt=0;
- if(cycle<3) cycle=3;
- else if(cycle<5) cycle++;
- else if(cycle<7) cycle+=9;
- else cycle+=15;
-
- for(lop=0;lop*8<len;lop++,buf+=8) {
- if(lop<20 || (type==0 && lop%cycle==0)){ // des
- BitConvert(buf,BitSwapTable1);
- BitConvert4(buf);
- BitConvert(buf,BitSwapTable2);
- } else {
- if(cnt==7 && type==0){
- int a;
- BYTE tmp[8];
- *(DWORD*)tmp = *(DWORD*)buf;
- *(DWORD*)(tmp+4) = *(DWORD*)(buf+4);
- cnt=0;
- buf[0]=tmp[3];
- buf[1]=tmp[4];
- buf[2]=tmp[6];
- buf[3]=tmp[0];
- buf[4]=tmp[1];
- buf[5]=tmp[2];
- buf[6]=tmp[5];
- a=tmp[7];
- if(a==0x00) a=0x2b;
- else if(a==0x2b) a=0x00;
- else if(a==0x01) a=0x68;
- else if(a==0x68) a=0x01;
- else if(a==0x48) a=0x77;
- else if(a==0x77) a=0x48;
- else if(a==0x60) a=0xff;
- else if(a==0xff) a=0x60;
- else if(a==0x6c) a=0x80;
- else if(a==0x80) a=0x6c;
- else if(a==0xb9) a=0xc0;
- else if(a==0xc0) a=0xb9;
- else if(a==0xeb) a=0xfe;
- else if(a==0xfe) a=0xeb;
- buf[7]=a;
- }
- cnt++;
- }
- }
-}
-/*==========================================
- * Grf data decode sub : zip
- *------------------------------------------
- */
int decode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen)
{
z_stream stream;
@@ -402,630 +157,3 @@ int deflate_file (const char *source, const char *filename)
return 0;
}
-
-unsigned long grfio_crc32 (const unsigned char *buf, unsigned int len)
-{
- return crc32(crc32(0L, Z_NULL, 0), buf, len);
-}
-
-/***********************************************************
- *** File List Subroutines ***
- ***********************************************************/
-
-/*==========================================
- * File List : Hash make
- *------------------------------------------
- */
-static int filehash(unsigned char *fname)
-{
- unsigned int hash=0;
- while(*fname) {
- hash = ((hash<<1)+(hash>>7)*9+tolower(*fname));
- fname++;
- }
- return hash & 255;
-}
-
-/*==========================================
- * File List : Hash initalize
- *------------------------------------------
- */
-static void hashinit(void)
-{
- int lop;
- for (lop = 0; lop < 256; lop++)
- filelist_hash[lop] = -1;
-}
-
-/*==========================================
- * File List : File find
- *------------------------------------------
- */
-static FILELIST *filelist_find(char *fname)
-{
- int hash;
-
- if (!filelist)
- return NULL;
-
- for (hash = filelist_hash[filehash((unsigned char *) fname)]; hash >= 0; hash = filelist[hash].next) {
- if(strcmpi(filelist[hash].fn, fname) == 0)
- break;
- }
-
- return (hash >= 0) ? &filelist[hash] : NULL;
-}
-
-char *grfio_find_file(char *fname){
- FILELIST *filelist = filelist_find(fname);
- if (!filelist) return NULL;
- return (!filelist->fnd?filelist->fn:filelist->fnd);
-}
-
-/*==========================================
- * File List : Filelist add
- *------------------------------------------
- */
-#define FILELIST_ADDS 1024 // number increment of file lists `
-
-static FILELIST* filelist_add(FILELIST *entry)
-{
- int hash;
-
- if (filelist_entrys >= FILELIST_LIMIT) {
- ShowFatalError("GRF filelist limit reached (filelist_add)!\n");
- exit(1);
- }
-
- if (filelist_entrys >= filelist_maxentry) {
- filelist = (FILELIST *)aRealloc(filelist, (filelist_maxentry + FILELIST_ADDS) * sizeof(FILELIST));
- memset(filelist + filelist_maxentry, '\0', FILELIST_ADDS * sizeof(FILELIST));
- filelist_maxentry += FILELIST_ADDS;
- }
-
- memcpy (&filelist[filelist_entrys], entry, sizeof(FILELIST));
-
- hash = filehash((unsigned char *) entry->fn);
- filelist[filelist_entrys].next = filelist_hash[hash];
- filelist_hash[hash] = filelist_entrys;
-
- filelist_entrys++;
-
- return &filelist[filelist_entrys - 1];
-}
-
-static FILELIST* filelist_modify(FILELIST *entry)
-{
- FILELIST *fentry;
- if ((fentry = filelist_find(entry->fn)) != NULL) {
- int tmp = fentry->next;
- memcpy(fentry, entry, sizeof(FILELIST));
- fentry->next = tmp;
- } else {
- fentry = filelist_add(entry);
- }
- return fentry;
-}
-
-/*==========================================
- * File List : filelist size adjust
- *------------------------------------------
- */
-static void filelist_adjust(void)
-{
- if (filelist != NULL) {
- if (filelist_maxentry > filelist_entrys) {
- filelist = (FILELIST *)aRealloc(
- filelist, filelist_entrys * sizeof(FILELIST));
- filelist_maxentry = filelist_entrys;
- }
- }
-}
-
-/***********************************************************
- *** Grfio Sobroutines ***
- ***********************************************************/
-
-/*==========================================
- * Grfio : Resource file size get
- *------------------------------------------
- */
-int grfio_size(char *fname)
-{
- FILELIST *entry;
-
- entry = filelist_find(fname);
-
- if (entry == NULL || entry->gentry < 0) { // LocalFileCheck
- char lfname[256], *p;
- FILELIST lentry;
- struct stat st;
-
- sprintf(lfname, "%s%s", data_dir, fname);
-
- for (p = &lfname[0]; *p != 0; p++)
- if (*p=='\\') *p = '/'; // * At the time of Unix
-
- if (stat(lfname, &st) == 0) {
- strncpy(lentry.fn, fname, sizeof(lentry.fn) - 1);
- lentry.fnd = NULL;
- lentry.declen = st.st_size;
- lentry.gentry = 0; // 0:LocalFile
- entry = filelist_modify(&lentry);
- } else if (entry == NULL) {
- ShowError("%s not found (grfio_size)\n", fname);
- //exit(1);
- return -1;
- }
- }
- return entry->declen;
-}
-
-/*==========================================
- * Grfio : Resource file read & size get
- *------------------------------------------
- */
-void* grfio_reads(char *fname, int *size)
-{
- FILE *in;
- FILELIST *entry;
- unsigned char *buf2 = NULL;
-
- entry = filelist_find(fname);
-
- if (entry == NULL || entry->gentry <= 0) { // LocalFileCheck
- char lfname[256], *p;
- FILELIST lentry;
-
- sprintf(lfname, "%s%s", data_dir, fname);
-
- for (p = &lfname[0]; *p != 0; p++)
- if (*p == '\\') *p = '/'; // * At the time of Unix
-
- in = fopen(lfname, "rb");
- if (in != NULL) {
- if (entry != NULL && entry->gentry == 0) {
- lentry.declen = entry->declen;
- } else {
- fseek(in,0,2); // SEEK_END
- lentry.declen = ftell(in);
- }
- fseek(in,0,0); // SEEK_SET
- buf2 = (unsigned char *)aMallocA(lentry.declen + 1024);
- fread(buf2, 1, lentry.declen, in);
- fclose(in);
- strncpy(lentry.fn, fname, sizeof(lentry.fn) - 1);
- lentry.fnd = NULL;
- lentry.gentry = 0; // 0:LocalFile
- entry = filelist_modify(&lentry);
- } else {
- if (entry != NULL && entry->gentry < 0) {
- entry->gentry = -entry->gentry; // local file checked
- } else {
- ShowError("%s not found (grfio_reads - local file %s)\n", fname, lfname);
- return NULL;
- }
- }
- }
- if (entry != NULL && entry->gentry > 0) { // Archive[GRF] File Read
- char *gfname = gentry_table[entry->gentry - 1];
- in = fopen(gfname, "rb");
- if(in != NULL) {
- unsigned char *buf = (unsigned char *)aMallocA(entry->srclen_aligned + 1024);
- fseek(in, entry->srcpos, 0);
- fread(buf, 1, entry->srclen_aligned, in);
- fclose(in);
- buf2 = (unsigned char *)aMallocA(entry->declen + 1024);
- if (entry->type == 1 || entry->type == 3 || entry->type == 5) {
- uLongf len;
- if (entry->cycle >= 0)
- decode_des_etc(buf, entry->srclen_aligned, entry->cycle == 0, entry->cycle);
- len = entry->declen;
- decode_zip(buf2, &len, buf, entry->srclen);
- if (len != entry->declen) {
- ShowError("decode_zip size miss match err: %d != %d\n", (int)len, entry->declen);
- aFree(buf);
- aFree(buf2);
- return NULL;
- }
- } else {
- memcpy(buf2, buf, entry->declen);
- }
- aFree(buf);
- } else {
- ShowError("%s not found (grfio_reads - grf file %s)\n", fname, gfname);
- return NULL;
- }
- }
- if (size != NULL && entry != NULL)
- *size = entry->declen;
-
- return buf2;
-}
-
-/*==========================================
- * Resource filename decode
- *------------------------------------------
- */
-static char * decode_filename(unsigned char *buf,int len)
-{
- int lop;
- for(lop=0;lop<len;lop+=8) {
- NibbleSwap(&buf[lop],8);
- BitConvert(&buf[lop],BitSwapTable1);
- BitConvert4(&buf[lop]);
- BitConvert(&buf[lop],BitSwapTable2);
- }
- return (char*)buf;
-}
-
-/*==========================================
- * Grfio : Entry table read
- *------------------------------------------
- */
-static int grfio_entryread(char *gfname,int gentry)
-{
- FILE *fp;
- long grf_size,list_size;
- unsigned char grf_header[0x2e];
- int lop,entry,entrys,ofs,grf_version;
- char *fname;
- unsigned char *grf_filelist;
-
- fp = fopen(gfname, "rb");
- if (fp == NULL) {
- ShowWarning("GRF Data File not found: '"CL_WHITE"%s"CL_RESET"'.\n",gfname);
- return 1; // 1:not found error
- }
-
- fseek(fp,0,2); // SEEK_END
- grf_size = ftell(fp);
- fseek(fp,0,0); // SEEK_SET
- fread(grf_header,1,0x2e,fp);
- if (strcmp((const char *) grf_header,"Master of Magic") ||
- fseek(fp,getlong(grf_header+0x1e),1)) // SEEK_CUR
- {
- fclose(fp);
- ShowError("GRF %s read error\n",gfname);
- return 2; // 2:file format error
- }
-
- grf_version = getlong(grf_header+0x2a) >> 8;
-
- if (grf_version == 0x01) { //****** Grf version 01xx ******
- list_size = grf_size - ftell(fp);
- grf_filelist = (unsigned char *) aMallocA(list_size);
- /*if (grf_filelist == NULL){
- fclose(fp);
- ShowError("out of memory : grf_filelist\n");
- return 3; // 3:memory alloc error
- }*/
- fread(grf_filelist,1,list_size,fp);
- fclose(fp);
-
- entrys = getlong(grf_header+0x26) - getlong(grf_header+0x22) - 7;
-
- // Get an entry
- for (entry = 0,ofs = 0; entry < entrys; entry++) {
- int ofs2, srclen, srccount, type;
- char *period_ptr;
- FILELIST aentry;
-
- ofs2 = ofs+getlong(grf_filelist+ofs)+4;
- type = grf_filelist[ofs2+12];
- if (type != 0) { // Directory Index ... skip
- fname = decode_filename(grf_filelist+ofs+6, grf_filelist[ofs]-6);
- if (strlen(fname) > sizeof(aentry.fn) - 1) {
- ShowFatalError("GRF file name %s is too long\n", fname);
- aFree(grf_filelist);
- exit(1);
- }
- srclen = 0;
- if ((period_ptr = strrchr(fname, '.')) != NULL) {
- for(lop = 0; lop < 4; lop++) {
- if (strcmpi(period_ptr, ".gnd\0.gat\0.act\0.str"+lop*5) == 0)
- break;
- }
- srclen = getlong(grf_filelist+ofs2) - getlong(grf_filelist+ofs2+8) - 715;
- if(lop == 4) {
- for(lop = 10, srccount = 1; srclen >= lop; lop = lop * 10, srccount++);
- } else {
- srccount = 0;
- }
- } else {
- srccount = 0;
- }
-
- aentry.srclen = srclen;
- aentry.srclen_aligned = getlong(grf_filelist+ofs2+4)-37579;
- aentry.declen = getlong(grf_filelist+ofs2+8);
- aentry.srcpos = getlong(grf_filelist+ofs2+13)+0x2e;
- aentry.cycle = srccount;
- aentry.type = type;
- strncpy(aentry.fn, fname,sizeof(aentry.fn)-1);
- aentry.fnd = NULL;
-#ifdef GRFIO_LOCAL
- aentry.gentry = -(gentry+1); // As Flag for making it a negative number carrying out the first time LocalFileCheck
-#else
- aentry.gentry = gentry+1; // With no first time LocalFileCheck
-#endif
- filelist_modify(&aentry);
- }
- ofs = ofs2 + 17;
- }
- aFree(grf_filelist);
-
- } else if (grf_version == 0x02) { //****** Grf version 02xx ******
- unsigned char eheader[8];
- unsigned char *rBuf;
- uLongf rSize, eSize;
-
- fread(eheader,1,8,fp);
- rSize = getlong(eheader); // Read Size
- eSize = getlong(eheader+4); // Extend Size
-
- if ((long)rSize > grf_size-ftell(fp)) { // Warning fix [Lance]
- fclose(fp);
- ShowError("Illegal data format : grf compress entry size\n");
- return 4;
- }
-
- rBuf = (unsigned char *)aMallocA(rSize); // Get a Read Size
- /*if (rBuf==NULL) {
- fclose(fp);
- ShowError("out of memory : grf compress entry table buffer\n");
- return 3;
- }*/
- grf_filelist = (unsigned char *)aMallocA(eSize); // Get a Extend Size
- /*if (grf_filelist==NULL) {
- aFree(rBuf);
- fclose(fp);
- ShowError("out of memory : grf extract entry table buffer\n");
- return 3;
- }*/
- fread(rBuf,1,rSize,fp);
- fclose(fp);
- decode_zip(grf_filelist, &eSize, rBuf, rSize); // Decode function
- list_size = eSize;
- aFree(rBuf);
-
- entrys = getlong(grf_header+0x26) - 7;
-
- // Get an entry
- for(entry = 0, ofs = 0; entry < entrys; entry++){
- int ofs2, srclen, srccount, type;
- FILELIST aentry;
-
- fname = (char*)(grf_filelist+ofs);
- if (strlen(fname) > sizeof(aentry.fn)-1) {
- ShowFatalError("GRF file name %s is too long\n", fname);
- aFree(grf_filelist);
- exit(1);
- }
- //ofs2 = ofs+strlen((char*)(grf_filelist+ofs))+1;
- ofs2 = ofs + strlen(fname)+1;
- type = grf_filelist[ofs2+12];
- if (type == 1 || type == 3 || type == 5) {
- srclen = getlong(grf_filelist+ofs2);
- if (grf_filelist[ofs2+12] == 3) {
- for (lop = 10, srccount = 1; srclen >= lop; lop = lop * 10, srccount++);
- } else if (grf_filelist[ofs2+12] == 5) {
- srccount = 0;
- } else { // if (grf_filelist[ofs2+12]==1) {
- srccount = -1;
- }
-
- aentry.srclen = srclen;
- aentry.srclen_aligned = getlong(grf_filelist+ofs2+4);
- aentry.declen = getlong(grf_filelist+ofs2+8);
- aentry.srcpos = getlong(grf_filelist+ofs2+13)+0x2e;
- aentry.cycle = srccount;
- aentry.type = type;
- strncpy(aentry.fn,fname,sizeof(aentry.fn)-1);
- aentry.fnd = NULL;
-#ifdef GRFIO_LOCAL
- aentry.gentry = -(gentry+1); // As Flag for making it a negative number carrying out the first time LocalFileCheck
-#else
- aentry.gentry = gentry+1; // With no first time LocalFileCheck
-#endif
- filelist_modify(&aentry);
- }
- ofs = ofs2 + 17;
- }
- aFree(grf_filelist);
-
- } else { //****** Grf Other version ******
- fclose(fp);
- ShowError("GRF version %04x not supported\n",getlong(grf_header+0x2a));
- return 4;
- }
-
- filelist_adjust(); // Unnecessary area release of filelist
-
- return 0; // 0:no error
-}
-
-/*==========================================
- * Grfio : Resource file check
- *------------------------------------------
- */
-static void grfio_resourcecheck(void)
-{
- char w1[256], w2[256], src[256], dst[256], restable[256], line[256];
- char *ptr, *buf;
- FILELIST *entry;
- int size, i = 0;
- FILE *fp;
-
- // read resnametable from data directory and return if successful
- sprintf(restable, "%sdata\\resnametable.txt", data_dir);
- for (ptr = &restable[0]; *ptr != 0; ptr++)
- if (*ptr == '\\') *ptr = '/';
-
- fp = fopen(restable,"rb");
- if (fp) {
- while (fgets(line, sizeof(line) - 1, fp)) {
- if (sscanf(line, "%[^#]#%[^#]#", w1, w2) == 2 &&
- // we only need the map names and text files
- (strstr(w2, ".gat") || strstr(w2, ".txt")))
- {
- sprintf(src, "data\\%s", w1);
- sprintf(dst, "data\\%s", w2);
- entry = filelist_find(dst);
- // create new entries reusing the original's info
- if (entry != NULL) {
- FILELIST fentry;
- memcpy(&fentry, entry, sizeof(FILELIST));
- strncpy(fentry.fn, src, sizeof(fentry.fn) - 1);
- fentry.fnd = grfio_alloc_ptr(dst);
- filelist_modify(&fentry);
- i++;
- }
- }
- }
- fclose(fp);
- ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", i, "resnametable.txt");
- return; // we're done here!
- }
-
- // read resnametable from loaded GRF's, only if it cannot be
- // loaded from the data directory
- buf = (char *)grfio_reads("data\\resnametable.txt", &size);
- if (buf) {
- buf[size] = 0;
- ptr = buf;
-
- while (ptr - buf < size) {
- if (sscanf(ptr, "%[^#]#%[^#]#", w1, w2) == 2 &&
- (strstr(w2, ".gat") || strstr(w2, ".txt")))
- {
- sprintf(src, "data\\%s", w1);
- sprintf(dst, "data\\%s", w2);
- entry = filelist_find(dst);
- if (entry != NULL) {
- FILELIST fentry;
- memcpy(&fentry, entry, sizeof(FILELIST));
- strncpy(fentry.fn, src, sizeof(fentry.fn) - 1);
- fentry.fnd = grfio_alloc_ptr(dst);
- filelist_modify(&fentry);
- i++;
- }
- }
- ptr = strchr(ptr,'\n'); // Next line
- if (!ptr) break;
- ptr++;
- }
- aFree(buf);
- ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", i, "data\\resnametable.txt");
- return;
- }
-
- //ShowWarning("GRF: No resnametable found! Panic?\n");
-}
-
-/*==========================================
- * Grfio : Resource add
- *------------------------------------------
- */
-#define GENTRY_ADDS 4 // The number increment of gentry_table entries
-
-static int grfio_add(char *fname)
-{
- grfio_alloc_ptr(fname);
-
- return grfio_entryread(fname, gentry_entrys - 1);
-}
-
-char *grfio_alloc_ptr(char *fname)
-{
- int len;
- char *buf;
-
- if (gentry_entrys >= GENTRY_LIMIT) {
- ShowFatalError("gentrys limit : grfio_add\n");
- exit(1);
- }
-
- if (gentry_entrys >= gentry_maxentry) {
- gentry_maxentry += GENTRY_ADDS;
- gentry_table = (char**)aRealloc(gentry_table, gentry_maxentry * sizeof(char*));
- memset(gentry_table + (gentry_maxentry - GENTRY_ADDS), 0, sizeof(char*) * GENTRY_ADDS);
- }
- len = strlen( fname );
- buf = (char*)aMallocA(len + 1);
- strcpy(buf, fname);
- gentry_table[gentry_entrys++] = buf;
-
- return buf;
-}
-
-/*==========================================
- * Grfio : Finalize
- *------------------------------------------
- */
-void grfio_final(void)
-{
- if (filelist != NULL)
- aFree(filelist);
-
- filelist_entrys = filelist_maxentry = 0;
-
- if (gentry_table != NULL) {
- int lop;
- for (lop = 0; lop < gentry_entrys; lop++) {
- if (gentry_table[lop] != NULL)
- aFree(gentry_table[lop]);
- }
- aFree(gentry_table);
- }
- gentry_table = NULL;
- gentry_entrys = gentry_maxentry = 0;
-}
-
-/*==========================================
- * Grfio : Initialize
- *------------------------------------------
- */
-void grfio_init(char *fname)
-{
- FILE *data_conf;
- char line[1024], w1[1024], w2[1024];
- int result = 0;
-
- hashinit(); // hash table initialization
-
- data_conf = fopen(fname, "r");
- // It will read, if there is grf-files.txt.
- if (data_conf) {
- while(fgets(line, sizeof(line) - 1, data_conf)) {
- if (line[0] == '/' && line[1] == '/')
- continue;
- if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
- continue;
- // Entry table reading
- if(strcmp(w1, "grf") == 0 ||
- strcmp(w1, "data") == 0 || // Primary data file
- strcmp(w1, "sdata") == 0 || // Sakray data file
- strcmp(w1, "adata") == 0) // Alpha version data file
- // increment if successfully loaded
- result += (grfio_add(w2) == 0);
- else if(strcmp(w1,"data_dir") == 0) // Data directory
- strcpy(data_dir, w2);
- }
-
- fclose(data_conf);
- ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n", fname);
- } // end of reading grf-files.txt
-
- if (result == 0) {
- ShowInfo("No grf's loaded.. using default data directory\n");
- //exit(1); // It ends, if a resource cannot read one.
- }
-
- // Unnecessary area release of filelist
- filelist_adjust();
- // Resource check
- grfio_resourcecheck();
-
- return;
-}
diff --git a/src/common/mapindex.c b/src/common/mapindex.c
index 01489ce93..439075b99 100644
--- a/src/common/mapindex.c
+++ b/src/common/mapindex.c
@@ -20,11 +20,11 @@ struct indexes {
static unsigned short max_index = 0;
-char mapindex_cfgfile[80] = "db/map_index.txt";
+char mapindex_cfgfile[80] = "db/map_list.txt";
/// Adds a map to the specified index
/// Returns 1 if successful, 0 oherwise
-static int mapindex_addmap(int index, const char *name)
+int mapindex_addmap(int index, const char *name)
{
char map_name[1024];
char *ext;
@@ -41,25 +41,13 @@ static int mapindex_addmap(int index, const char *name)
ShowError("(mapindex_add) Map name %s is too long. Maps are limited to %d characters.\n", map_name, MAP_NAME_LENGTH);
return 0;
}
- if ((ext = strstr(map_name, ".gat")) != NULL) { //Gat map
+ if ((ext = strstr(map_name, ".")) != NULL) { // Remove extension
length = ext-map_name;
- } else if ((ext = strstr(map_name, ".afm")) != NULL || (ext = strstr(map_name, ".af2")) != NULL) { //afm map
- length = ext-map_name;
- sprintf(ext, ".gat"); //Change the extension to gat
- } else if ((ext = strstr(map_name, ".")) != NULL) { //Generic extension?
- length = ext-map_name;
- sprintf(ext, ".gat");
- } else { //No extension?
- length = strlen(map_name);
- strcat(map_name, ".gat");
- }
- if (length > MAP_NAME_LENGTH - 4) {
- ShowError("(mapindex_add) Adjusted Map name %s is too long. Maps are limited to %d characters.\n", map_name, MAP_NAME_LENGTH);
- return 0;
+ sprintf(ext, "\0");
}
if (indexes[index].length)
- ShowWarning("(mapindex_add) Overriding index %d: map \"%s\" -> \"%s\"\n", indexes[index].name, map_name);
+ ShowWarning("(mapindex_add) Overriding index %d: map \"%s\" -> \"%s\"\n", index, indexes[index].name, map_name);
strncpy(indexes[index].name, map_name, MAP_NAME_LENGTH);
indexes[index].length = length;
@@ -77,7 +65,7 @@ unsigned short mapindex_name2id(const char* name) {
length = ext-name; //Base map-name length without the extension.
for (i = 1; i < max_index; i++)
{
- if (indexes[i].length == length && strncmp(indexes[i].name,name,length)==0)
+ if (strncmp(indexes[i].name,name,length)==0)
return i;
}
#ifdef MAPINDEX_AUTOADD
diff --git a/src/common/mapindex.h b/src/common/mapindex.h
index a4aabbc7b..dfcb150e2 100644
--- a/src/common/mapindex.h
+++ b/src/common/mapindex.h
@@ -12,31 +12,32 @@ extern char mapindex_cfgfile[80];
//#define MAPINDEX_AUTOADD
//Some definitions for the mayor city maps.
-#define MAP_PRONTERA "prontera.gat"
-#define MAP_GEFFEN "geffen.gat"
-#define MAP_MORROC "morocc.gat"
-#define MAP_ALBERTA "alberta.gat"
-#define MAP_PAYON "payon.gat"
-#define MAP_IZLUDE "izlude.gat"
-#define MAP_ALDEBARAN "aldebaran.gat"
-#define MAP_LUTIE "xmas.gat"
-#define MAP_COMODO "comodo.gat"
-#define MAP_YUNO "yuno.gat"
-#define MAP_AMATSU "amatsu.gat"
-#define MAP_GONRYUN "gonryun.gat"
-#define MAP_UMBALA "umbala.gat"
-#define MAP_NIFLHEIM "niflheim.gat"
-#define MAP_LOUYANG "louyang.gat"
-#define MAP_JAWAII "jawaii.gat"
-#define MAP_AYOTHAYA "ayothaya.gat"
-#define MAP_EINBROCH "einbroch.gat"
-#define MAP_LIGHTHALZEN "lighthalzen.gat"
-#define MAP_EINBECH "einbech.gat"
-#define MAP_HUGEL "hugel.gat"
-#define MAP_RACHEL "rachel.gat"
-#define MAP_VEINS "veins.gat"
-#define MAP_JAIL "sec_pri.gat"
-#define MAP_NOVICE "new_zone01.gat"
+#define MAP_PRONTERA "prontera"
+#define MAP_GEFFEN "geffen"
+#define MAP_MORROC "morocc"
+#define MAP_ALBERTA "alberta"
+#define MAP_PAYON "payon"
+#define MAP_IZLUDE "izlude"
+#define MAP_ALDEBARAN "aldebaran"
+#define MAP_LUTIE "xmas"
+#define MAP_COMODO "comodo"
+#define MAP_YUNO "yuno"
+#define MAP_AMATSU "amatsu"
+#define MAP_GONRYUN "gonryun"
+#define MAP_UMBALA "umbala"
+#define MAP_NIFLHEIM "niflheim"
+#define MAP_LOUYANG "louyang"
+#define MAP_JAWAII "jawaii"
+#define MAP_AYOTHAYA "ayothaya"
+#define MAP_EINBROCH "einbroch"
+#define MAP_LIGHTHALZEN "lighthalzen"
+#define MAP_EINBECH "einbech"
+#define MAP_HUGEL "hugel"
+#define MAP_RACHEL "rachel"
+#define MAP_VEINS "veins"
+#define MAP_JAIL "sec_pri"
+#define MAP_NOVICE "new_zone01"
+int mapindex_addmap(int index, const char *name);
unsigned short mapindex_name2id(const char*);
const char* mapindex_id2name(unsigned short);
void mapindex_init(void);
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
*------------------------------------------
*/
diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c
index e73723e66..79de65e0b 100644
--- a/src/tool/mapcache.c
+++ b/src/tool/mapcache.c
@@ -12,8 +12,8 @@
#include "grfio.h"
-char grf_list_file[256] = "tools/mapcache/grf_files.txt";
-char map_list_file[256] = "tools/mapcache/map_list.txt";
+char grf_list_file[256] = "db/grf_files.txt";
+char map_list_file[256] = "db/map_list.txt";
char map_cache_file[256] = "db/map_cache.dat";
#define MAP_NAME_LENGTH 16
@@ -226,8 +226,7 @@ int main(int argc, char *argv[])
printf("Map file not found in GRF\n");
// If the 2nd argument is omitted at next line, we'll keep last used index + 1
index++;
- } else
- printf("Skipping incorrect line\n");
+ }
}
printf("Closing map list: %s\n", map_list_file);