summaryrefslogtreecommitdiff
path: root/src/map/map.c
diff options
context:
space:
mode:
authorcelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-02-22 16:08:24 +0000
committercelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-02-22 16:08:24 +0000
commitf65bf4bd28cd9240c889bfd2a1f4650d91760a2d (patch)
tree6730a4d5ca802cc2c4cdb128dca07f1e95cac0fb /src/map/map.c
parent6b0b62a5b2a9d85f60afe4fe048403101bd8f39d (diff)
downloadhercules-f65bf4bd28cd9240c889bfd2a1f4650d91760a2d.tar.gz
hercules-f65bf4bd28cd9240c889bfd2a1f4650d91760a2d.tar.bz2
hercules-f65bf4bd28cd9240c889bfd2a1f4650d91760a2d.tar.xz
hercules-f65bf4bd28cd9240c889bfd2a1f4650d91760a2d.zip
* Corrected Spiral Pierce's hits in the skill_db
* Moved /common/*.o into a obj folder when compiling * Updated core and map server to jA 1094~1115 git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1162 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/map.c')
-rw-r--r--src/map/map.c152
1 files changed, 122 insertions, 30 deletions
diff --git a/src/map/map.c b/src/map/map.c
index ee597789c..d402ac06c 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -403,12 +403,13 @@ int map_count_oncell(int m, int x, int y) {
/*
* «»«E¾ªÎõÌôøªË̸ªÄª±ª¿«¹«­«Eæ«Ë«Ã«ÈªòÚ÷ª¹
*/
-struct skill_unit *map_find_skill_unit_oncell(int m,int x,int y,int skill_id)
+struct skill_unit *map_find_skill_unit_oncell(struct block_list *target,int x,int y,int skill_id,struct skill_unit *out_unit)
{
- int bx,by;
+ int m,bx,by;
struct block_list *bl;
int i,c;
struct skill_unit *unit;
+ m = target->m;
if (x < 0 || y < 0 || (x >= map[m].xs) || (y >= map[m].ys))
return NULL;
@@ -421,7 +422,10 @@ struct skill_unit *map_find_skill_unit_oncell(int m,int x,int y,int skill_id)
if (bl->x != x || bl->y != y || bl->type != BL_SKILL)
continue;
unit = (struct skill_unit *) bl;
- if (unit->alive && unit->group->skill_id == skill_id)
+ if (unit==out_unit || !unit->alive ||
+ !unit->group || unit->group->skill_id!=skill_id)
+ continue;
+ if (battle_check_target(&unit->bl,target,unit->group->target_flag)>0)
return unit;
}
return NULL;
@@ -1622,7 +1626,7 @@ struct map_session_data * map_nick2sd(char *nick) {
struct block_list * map_id2bl(int id)
{
struct block_list *bl=NULL;
- if(id<sizeof(objects)/sizeof(objects[0]))
+ if(id >= 0 && id < sizeof(objects)/sizeof(objects[0]))
bl = objects[id];
else
bl = (struct block_list*)numdb_search(id_db,id);
@@ -1826,7 +1830,7 @@ int map_getcell(int m,int x,int y,cell_t cellchk)
int map_getcellp(struct map_data* m,int x,int y,cell_t cellchk)
{
- int j;
+ int type;
nullpo_ret(m);
if(x<0 || x>=m->xs-1 || y<0 || y>=m->ys-1)
@@ -1834,24 +1838,28 @@ int map_getcellp(struct map_data* m,int x,int y,cell_t cellchk)
if(cellchk==CELL_CHKNOPASS) return 1;
return 0;
}
- j=x+y*m->xs;
+ type = m->gat[x+y*m->xs];
+ if (cellchk<0x10)
+ type &= CELL_MASK;
switch(cellchk)
{
case CELL_CHKPASS:
- return (m->gat[j] != 1 && m->gat[j] != 5);
+ return (type!=1 && type!=5);
case CELL_CHKNOPASS:
- return (m->gat[j] == 1 || m->gat[j] == 5);
+ return (type==1 || type==5);
case CELL_CHKWALL:
- return (m->gat[j] == 1);
- case CELL_CHKNPC:
- return (m->gat[j]&0x80);
+ return (type==1);
case CELL_CHKWATER:
- return (m->gat[j] == 3);
+ return (type==3);
case CELL_CHKGROUND:
- return (m->gat[j] == 5);
+ return (type==5);
case CELL_GETTYPE:
- return m->gat[j];
+ return type;
+ case CELL_CHKNPC:
+ return (type&CELL_NPC);
+ case CELL_CHKBASILICA:
+ return (type&CELL_BASILICA);
default:
return 0;
}
@@ -1868,10 +1876,20 @@ void map_setcell(int m,int x,int y,int cell)
return;
j=x+y*map[m].xs;
- if (cell == CELL_SETNPC)
- map[m].gat[j] |= 0x80;
- else
- map[m].gat[j] = cell;
+ switch (cell) {
+ case CELL_SETNPC:
+ map[m].gat[j] |= CELL_NPC;
+ break;
+ case CELL_SETBASILICA:
+ map[m].gat[j] |= CELL_BASILICA;
+ break;
+ case CELL_CLRBASILICA:
+ map[m].gat[j] &= ~CELL_BASILICA;
+ break;
+ default:
+ map[m].gat[j] = (map[m].gat[j]&~CELL_MASK) + cell;
+ break;
+ }
}
/*==========================================
@@ -1889,15 +1907,39 @@ int map_setipport(char *name,unsigned long ip,int port) {
mdos->gat = NULL;
mdos->ip = ip;
mdos->port = port;
+ mdos->map = NULL;
strdb_insert(map_db,mdos->name,mdos);
+ } else if(md->gat){
+ if(ip!=clif_getip() || port!=clif_getport()){
+ // “Ç‚Ýž‚ñ‚Å‚¢‚½‚¯‚ÇA’S“–ŠO‚É‚È‚Á‚½ƒ}ƒbƒv
+ mdos=(struct map_data_other_server *)aCalloc(1,sizeof(struct map_data_other_server));
+ memcpy(mdos->name,name,24);
+ mdos->gat = NULL;
+ mdos->ip = ip;
+ mdos->port = port;
+ mdos->map = md;
+ strdb_insert(map_db,mdos->name,mdos);
+ // printf("from char server : %s -> %08lx:%d\n",name,ip,port);
+ } else {
+ // “Ç‚Ýž‚ñ‚Å‚¢‚ÄA’S“–‚É‚È‚Á‚½ƒ}ƒbƒvi‰½‚à‚µ‚È‚¢j
+ ;
+ }
} else {
- if(md->gat){ // local -> check data
- if(ip!=clif_getip() || port!=clif_getport()){
- printf("from char server : %s -> %08lx:%d\n",name,ip,port);
- return 1;
+ mdos=(struct map_data_other_server *)md;
+ if(ip == clif_getip() && port == clif_getport()) {
+ // Ž©•ª‚Ì’S“–‚É‚È‚Á‚½ƒ}ƒbƒv
+ if(mdos->map == NULL) {
+ // “Ç‚Ýž‚ñ‚Å‚¢‚È‚¢‚Ì‚ÅI—¹‚·‚é
+ printf("map_setipport : %s is not loaded.\n",name);
+ exit(1);
+ } else {
+ // “Ç‚Ýž‚ñ‚Å‚¢‚é‚Ì‚Å’u‚«Š·‚¦‚é
+ md = mdos->map;
+ free(mdos);
+ strdb_insert(map_db,md->name,md);
}
- } else { // update
- mdos=(struct map_data_other_server *)md;
+ } else {
+ // ‘¼‚ÌŽI‚Ì’S“–ƒ}ƒbƒv‚È‚Ì‚Å’u‚«Š·‚¦‚邾‚¯
mdos->ip = ip;
mdos->port = port;
}
@@ -1905,6 +1947,56 @@ int map_setipport(char *name,unsigned long ip,int port) {
return 0;
}
+/*==========================================
+ * ‘¼ŽIŠÇ—‚̃}ƒbƒv‚ð‘S‚Äíœ
+ *------------------------------------------
+ */
+int map_eraseallipport_sub(void *key,void *data,va_list va) {
+ struct map_data_other_server *mdos = (struct map_data_other_server*)data;
+ if(mdos->gat == NULL && mdos->map == NULL) {
+ strdb_erase(map_db,key);
+ free(mdos);
+ }
+ return 0;
+}
+
+int map_eraseallipport(void) {
+ strdb_foreach(map_db,map_eraseallipport_sub);
+ return 1;
+}
+
+/*==========================================
+ * ‘¼ŽIŠÇ—‚̃}ƒbƒv‚ðdb‚©‚çíœ
+ *------------------------------------------
+ */
+int map_eraseipport(char *name,unsigned long ip,int port)
+{
+ struct map_data *md;
+ struct map_data_other_server *mdos;
+// unsigned char *p=(unsigned char *)&ip;
+
+ md=strdb_search(map_db,name);
+ if(md){
+ if(md->gat) // local -> check data
+ return 0;
+ else {
+ mdos=(struct map_data_other_server *)md;
+ if(mdos->ip==ip && mdos->port == port) {
+ if(mdos->map) {
+ // ‚±‚̃}ƒbƒvŽI‚Å‚à“Ç‚Ýž‚ñ‚Å‚¢‚é‚̂ňړ®‚Å‚«‚é
+ return 1; // ŒÄ‚Ño‚µŒ³‚Å chrif_sendmap() ‚ð‚·‚é
+ } else {
+ strdb_erase(map_db,name);
+ free(mdos);
+ }
+// if(battle_config.etc_log)
+// printf("erase map %s %d.%d.%d.%d:%d\n",name,p[0],p[1],p[2],p[3],port);
+ }
+ }
+ }
+ return 0;
+}
+
// ‰Šú‰»Žü‚è
/*==========================================
* …ê‚‚³Ý’è
@@ -2043,7 +2135,7 @@ static void map_cache_close(void)
fwrite(map_cache.map,map_cache.head.nmaps,sizeof(struct map_cache_info),map_cache.fp);
}
fclose(map_cache.fp);
- free(map_cache.map);
+ aFree(map_cache.map);
map_cache.fp = NULL;
return;
}
@@ -2085,16 +2177,16 @@ int map_cache_read(struct map_data *m)
if(fread(buf,1,size_compress,map_cache.fp) != size_compress) {
// ‚È‚º‚©ƒtƒ@ƒCƒ‹Œã”¼‚ªŒ‡‚¯‚Ä‚é‚Ì‚Å“Ç‚Ý’¼‚µ
printf("fread error\n");
- m->xs = 0; m->ys = 0; m->gat = NULL;
- free(m->gat); free(buf);
+ free(m->gat); m->xs = 0; m->ys = 0; m->gat = NULL;
+ free(buf);
return 0;
}
dest_len = m->xs * m->ys;
decode_zip(m->gat,&dest_len,buf,size_compress);
if(dest_len != map_cache.map[i].xs * map_cache.map[i].ys) {
// ³í‚ɉ𓀂ªo—ˆ‚Ä‚È‚¢
- m->xs = 0; m->ys = 0; m->gat = NULL;
- free(m->gat); free(buf);
+ free(m->gat); m->xs = 0; m->ys = 0; m->gat = NULL;
+ free(buf);
return 0;
}
free(buf);
@@ -3069,7 +3161,7 @@ void do_final(void) {
strdb_final(nick_db, nick_db_final);
numdb_final(charid_db, charid_db_final);
-
+ do_final_chrif(); // ‚±‚Ì“à•”‚ŃLƒƒƒ‰‚ð‘S‚ÄØ’f‚·‚é
do_final_script();
do_final_itemdb();
do_final_storage();