diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/login/login.c | 1 | ||||
-rw-r--r-- | src/map/map.c | 91 | ||||
-rw-r--r-- | src/map/map.h | 1 | ||||
-rw-r--r-- | src/map/status.c | 5 |
4 files changed, 63 insertions, 35 deletions
diff --git a/src/login/login.c b/src/login/login.c index a1a4243fe..4ecdd2b80 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -3515,7 +3515,6 @@ int login_lan_config_read(const char *lancfgName) { return 0;
}
-
//-----------------------------------
// Reading general configuration file
//-----------------------------------
diff --git a/src/map/map.c b/src/map/map.c index 173241aca..c06f7ef1b 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2351,21 +2351,22 @@ int map_eraseipport(unsigned short mapindex,unsigned long ip,int port) *------------------------------------------
*/
static struct waterlist_ {
- char mapname[MAP_NAME_LENGTH];
- int waterheight;
+ char mapname[MAP_NAME_LENGTH], clonemapname[MAP_NAME_LENGTH];
} *waterlist=NULL;
#define NO_WATER 1000000
-static int map_setwaterheight_sub(int m, int wh) {
+static int map_setwaterheight_sub(int m) {
char fn[256];
char *gat;
int x,y;
+ int wh;
struct gat_1cell {float high[4]; int type;} *p = NULL;
if (m < 0)
return 0;
-
+ wh = map[m].water_height;
+
sprintf(fn,"data\\%s",mapindex_id2name(map[m].index));
// read & convert fn
@@ -2388,34 +2389,56 @@ static int map_setwaterheight_sub(int m, int wh) { return 1;
}
int map_setwaterheight(int m, char *mapname, int height) {
- int i=0;
if (height < 0)
height = NO_WATER;
- if(waterlist){
- for(i=0;waterlist[i].mapname[0] && i < MAX_MAP_PER_SERVER;i++)
- if(strcmp(waterlist[i].mapname,mapname)==0) {
- waterlist[i].waterheight = height;
- }
- }
- if (i < MAX_MAP_PER_SERVER) {
- memcpy(waterlist[i].mapname,mapname, MAP_NAME_LENGTH-1);
- waterlist[i].waterheight = height;
- }
- return map_setwaterheight_sub(m, height);
+ map[m].water_height = height;
+ return map_setwaterheight_sub(m);
}
+/* map_readwaterheight
+ * Reads from the .rsw for each map
+ * Returns water height (or NO_WATER if file doesn't exist)
+ * or other error is encountered.
+ * This receives a map-name, and changes the extension to rsw if it isn't set already.
+ * assumed path for file is data/mapname.rsw
+ * Credits to LittleWolf
+ */
int map_waterheight(char *mapname) {
+ char fn[256];
+ char *rsw;
+ float whtemp;
+ int wh;
+#ifdef _WIN32
+ sprintf(fn,"data\\%s",mapname);
+#else
+ sprintf(fn,"data/%s",mapname);
+#endif
+ rsw = strstr(fn, ".");
+ if (rsw && strstr(fn, ".rsw") == NULL)
+ strcat (rsw, "rsw");
+
+ // read & convert fn
+ // again, might not need to be unsigned char
+ rsw = (char *) grfio_read (fn);
+ if (rsw)
+ { //Load water height from file
+ whtemp = *(float*)(rsw+166);
+ wh = (int) whtemp;
+ aFree(rsw);
+ return wh;
+ }
+ //Look up for clone map.
if(waterlist){
int i;
for(i=0;waterlist[i].mapname[0] && i < MAX_MAP_PER_SERVER;i++)
if(strcmp(waterlist[i].mapname,mapname)==0)
- return waterlist[i].waterheight;
+ return map_waterheight(waterlist[i].clonemapname);
}
return NO_WATER;
}
static void map_readwater(char *watertxt) {
- char line[1024],w1[1024];
+ char line[1024],w1[1024],w2[1024];
FILE *fp=NULL;
int n=0;
@@ -2427,17 +2450,13 @@ static void map_readwater(char *watertxt) { if(waterlist==NULL)
waterlist = (struct waterlist_*)aCallocA(MAX_MAP_PER_SERVER,sizeof(*waterlist));
while(fgets(line,1020,fp) && n < MAX_MAP_PER_SERVER){
- int wh,count;
if(line[0] == '/' && line[1] == '/')
continue;
- if((count=sscanf(line,"%s%d",w1,&wh)) < 1){
+ if(sscanf(line,"%s %s",w1,w2) < 2){
continue;
}
memcpy(waterlist[n].mapname,w1, MAP_NAME_LENGTH-1);
- if(count >= 2)
- waterlist[n].waterheight = wh;
- else
- waterlist[n].waterheight = 3;
+ memcpy(waterlist[n].clonemapname, w2, MAP_NAME_LENGTH-1);
n++;
}
fclose(fp);
@@ -2538,14 +2557,12 @@ int map_cache_read(struct map_data *m) if(!map_cache.fp) { return 0; }
for(i = 0;i < map_cache.head.nmaps ; i++) {
if(!strcmp(m->name,map_cache.map[i].fn)) {
- if(map_cache.map[i].water_height != map_waterheight(m->name)) {
- // 水場の高さが違うので読み直し
- return 0;
- } else if(map_cache.map[i].compressed == 0) {
+ if(map_cache.map[i].compressed == 0) {
// 非圧縮ファイル
int size = map_cache.map[i].xs * map_cache.map[i].ys;
m->xs = map_cache.map[i].xs;
m->ys = map_cache.map[i].ys;
+ m->water_height = map_cache.map[i].water_height;
m->gat = (unsigned char *)aCalloc(m->xs * m->ys,sizeof(unsigned char));
fseek(map_cache.fp,map_cache.map[i].pos,SEEK_SET);
if(fread(m->gat,1,size,map_cache.fp) == size) {
@@ -2563,6 +2580,7 @@ int map_cache_read(struct map_data *m) int size_compress = map_cache.map[i].compressed_len;
m->xs = map_cache.map[i].xs;
m->ys = map_cache.map[i].ys;
+ m->water_height = map_cache.map[i].water_height;
m->gat = (unsigned char *)aMalloc(m->xs * m->ys * sizeof(unsigned char));
buf = (unsigned char*)aMalloc(size_compress);
fseek(map_cache.fp,map_cache.map[i].pos,SEEK_SET);
@@ -2633,7 +2651,7 @@ static int map_cache_write(struct map_data *m) }
map_cache.map[i].xs = m->xs;
map_cache.map[i].ys = m->ys;
- map_cache.map[i].water_height = map_waterheight(m->name);
+ map_cache.map[i].water_height = m->water_height;
map_cache.dirty = 1;
if(map_read_flag == 2) {
aFree(write_buf);
@@ -2663,7 +2681,7 @@ static int map_cache_write(struct map_data *m) map_cache.map[i].pos = map_cache.head.filesize;
map_cache.map[i].xs = m->xs;
map_cache.map[i].ys = m->ys;
- map_cache.map[i].water_height = map_waterheight(m->name);
+ map_cache.map[i].water_height = m->water_height;
map_cache.head.filesize += len_new;
map_cache.dirty = 1;
if(map_read_flag == 2) {
@@ -2803,7 +2821,8 @@ static int map_loadafm (struct map_data *m, char *fn) xs = m->xs = afm_size[0];
ys = m->ys = afm_size[1];
- // check this, unsigned where it might not need to be
+ m->water_height = map_waterheight(m->name);
+
m->gat = (unsigned char*)aCallocA(xs * ys, 1);
for (y = 0; y < ys; y++) {
@@ -2911,11 +2930,19 @@ int map_readgat (struct map_data *m) if ((pt = strstr(m->name,"<")) != NULL) { // [MouseJstr]
char buf[64];
*pt++ = '\0';
+#ifdef _WIN32
sprintf(buf,"data\\%s", pt);
+#else
+ sprintf(buf,"data/%s", pt);
+#endif
m->alias = aStrdup(buf);
}
+#ifdef _WIN32
sprintf(fn,"data\\%s",m->name);
+#else
+ sprintf(fn,"data/%s",m->name);
+#endif
// read & convert fn
// again, might not need to be unsigned char
@@ -2927,7 +2954,7 @@ int map_readgat (struct map_data *m) ys = m->ys = *(int*)(gat+10);
m->gat = (unsigned char *)aCallocA(m->xs * m->ys, sizeof(unsigned char));
- wh = map_waterheight(m->name);
+ m->water_height = wh = map_waterheight(m->name);
for (y = 0; y < ys; y++) {
p = (struct gat_1cell*)(gat+y*xs*20+14);
for (x = 0; x < xs; x++) {
diff --git a/src/map/map.h b/src/map/map.h index 77044ee8c..28bc785bc 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -997,6 +997,7 @@ struct map_data { int m;
short xs,ys;
short bxs,bys;
+ int water_height;
int npc_num;
int users;
struct {
diff --git a/src/map/status.c b/src/map/status.c index eb7f3eff2..32fd92d98 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -419,8 +419,9 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, int default: return 0;
}
}
- if (skill_num)
- { //Skills blocked through status changes...
+ if (skill_num && //Do not block item-casted skills.
+ (src->type != BL_PC || ((TBL_PC*)src)->skillitem != skill_num)
+ ) { //Skills blocked through status changes...
if (!flag && ( //Blocked only from using the skill (stuff like autospell may still go through
(sc->data[SC_MARIONETTE].timer != -1 && skill_num != CG_MARIONETTE) ||
(sc->data[SC_MARIONETTE2].timer != -1 && skill_num == CG_MARIONETTE) ||
|