diff options
author | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-10-11 19:49:55 +0000 |
---|---|---|
committer | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-10-11 19:49:55 +0000 |
commit | 75d8e3d12caacd6a538982bb5c31ff1ce6f34527 (patch) | |
tree | 1a2cd9402304e6b67d6db9ab71ad163d23190558 /src | |
parent | 47d2e59ecf47d9f4d68458eb95e4a05fee06d8fb (diff) | |
download | hercules-75d8e3d12caacd6a538982bb5c31ff1ce6f34527.tar.gz hercules-75d8e3d12caacd6a538982bb5c31ff1ce6f34527.tar.bz2 hercules-75d8e3d12caacd6a538982bb5c31ff1ce6f34527.tar.xz hercules-75d8e3d12caacd6a538982bb5c31ff1ce6f34527.zip |
- Cleaned up unitattack, unittalk and unitdeadsit
- Updated status_get_name to take into account fakename, also cleaned it up.
- Cleaned up the char-server code when the last point of a player is not found. First it'll check if there's any mapserver online, and then, if there is, it'll look for the major cities. If this fails, then the player will be told server is closed instead of trying to send him to a "random map".
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8967 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r-- | src/char/char.c | 57 | ||||
-rw-r--r-- | src/char_sql/char.c | 53 | ||||
-rw-r--r-- | src/map/script.c | 63 | ||||
-rw-r--r-- | src/map/status.c | 18 | ||||
-rw-r--r-- | src/map/trade.c | 9 |
5 files changed, 77 insertions, 123 deletions
diff --git a/src/char/char.c b/src/char/char.c index 691dcf2a4..c581629c0 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -3484,51 +3484,46 @@ int parse_char(int fd) { // if map is not found, we check major cities
if (i < 0) {
unsigned short j;
- ShowWarning("Unable to find map-server for '%s', resorting to sending to a major city.\n", mapindex_id2name(cd->last_point.map));
+ //First check that there's actually a map server online.
+ for(j = 0; j < MAX_MAP_SERVERS; j++)
+ if (server_fd[j] >= 0 && server[j].map[0])
+ break;
+ if (j == MAX_MAP_SERVERS) {
+ ShowInfo("Connection Closed. No map servers available.\n");
+ WFIFOHEAD(fd, 3);
+ WFIFOW(fd,0) = 0x81;
+ WFIFOB(fd,2) = 1; // 01 = Server closed
+ WFIFOSET(fd,3);
+ break;
+ }
if ((i = search_mapserver((j=mapindex_name2id(MAP_PRONTERA)),-1,-1)) >= 0) {
- cd->last_point.map = j;
- cd->last_point.x = 273; // savepoint coordinates
+ cd->last_point.x = 273;
cd->last_point.y = 354;
} else if ((i = search_mapserver((j=mapindex_name2id(MAP_GEFFEN)),-1,-1)) >= 0) {
- cd->last_point.map = j;
- cd->last_point.x = 120; // savepoint coordinates
+ cd->last_point.x = 120;
cd->last_point.y = 100;
} else if ((i = search_mapserver((j=mapindex_name2id(MAP_MORROC)),-1,-1)) >= 0) {
- cd->last_point.map = j;
- cd->last_point.x = 160; // savepoint coordinates
+ cd->last_point.x = 160;
cd->last_point.y = 94;
} else if ((i = search_mapserver((j=mapindex_name2id(MAP_ALBERTA)),-1,-1)) >= 0) {
- cd->last_point.map = j;
- cd->last_point.x = 116; // savepoint coordinates
+ cd->last_point.x = 116;
cd->last_point.y = 57;
} else if ((i = search_mapserver((j=mapindex_name2id(MAP_PAYON)),-1,-1)) >= 0) {
- cd->last_point.map = j;
- cd->last_point.x = 87; // savepoint coordinates
+ cd->last_point.x = 87;
cd->last_point.y = 117;
} else if ((i = search_mapserver((j=mapindex_name2id(MAP_IZLUDE)),-1,-1)) >= 0) {
- cd->last_point.map = j;
- cd->last_point.x = 94; // savepoint coordinates
+ cd->last_point.x = 94;
cd->last_point.y = 103;
} else {
- // get first online server (with a map)
- i = 0;
- for(j = 0; j < MAX_MAP_SERVERS; j++)
- if (server_fd[j] >= 0 && server[j].map[0]) { // change save point to one of map found on the server (the first)
- i = j;
- cd->last_point.map = server[j].map[0];
- ShowInfo("Map-server #%d found with a map: '%s'.\n", j, mapindex_id2name(server[j].map[0]));
- // coordinates are unknown
- break;
- }
- // if no map-server is connected, we send: server closed
- if (j == MAX_MAP_SERVERS) {
- WFIFOHEAD(fd, 3);
- WFIFOW(fd,0) = 0x81;
- WFIFOB(fd,2) = 1; // 01 = Server closed
- WFIFOSET(fd,3);
- break;
- }
+ ShowInfo("Connection Closed. No map server available that has a major city, and unable to find map-server for '%s'.\n", mapindex_id2name(cd->last_point.map));
+ WFIFOHEAD(fd, 3);
+ WFIFOW(fd,0) = 0x81;
+ WFIFOB(fd,2) = 1; // 01 = Server closed
+ WFIFOSET(fd,3);
+ break;
}
+ 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;
}
WFIFOHEAD(fd, 28);
WFIFOW(fd,0) = 0x71;
diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 629bbade8..b0c90be7a 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -3279,48 +3279,45 @@ int parse_char(int fd) { // if map is not found, we check major cities
if (i < 0) {
unsigned short j;
- ShowWarning("Unable to find map-server for '%s', resorting to sending to a major city.\n", mapindex_id2name(char_dat.last_point.map));
+ //First check that there's actually a map server online.
+ for(j = 0; j < MAX_MAP_SERVERS; j++)
+ if (server_fd[j] >= 0 && server[j].map[0])
+ break;
+ if (j == MAX_MAP_SERVERS) {
+ ShowInfo("Connection Closed. No map servers available.\n");
+ WFIFOHEAD(fd, 3);
+ WFIFOW(fd,0) = 0x81;
+ WFIFOB(fd,2) = 1; // 01 = Server closed
+ WFIFOSET(fd,3);
+ break;
+ }
if ((i = search_mapserver((j=mapindex_name2id(MAP_PRONTERA)),-1,-1)) >= 0) {
- char_dat.last_point.map = j;
- char_dat.last_point.x = 273; // savepoint coordinates
+ char_dat.last_point.x = 273;
char_dat.last_point.y = 354;
} else if ((i = search_mapserver((j=mapindex_name2id(MAP_GEFFEN)),-1,-1)) >= 0) {
- char_dat.last_point.map = j;
- char_dat.last_point.x = 120; // savepoint coordinates
+ char_dat.last_point.x = 120;
char_dat.last_point.y = 100;
} else if ((i = search_mapserver((j=mapindex_name2id(MAP_MORROC)),-1,-1)) >= 0) {
- char_dat.last_point.map = j;
- char_dat.last_point.x = 160; // savepoint coordinates
+ char_dat.last_point.x = 160;
char_dat.last_point.y = 94;
} else if ((i = search_mapserver((j=mapindex_name2id(MAP_ALBERTA)),-1,-1)) >= 0) {
- char_dat.last_point.map = j;
- char_dat.last_point.x = 116; // savepoint coordinates
+ char_dat.last_point.x = 116;
char_dat.last_point.y = 57;
} else if ((i = search_mapserver((j=mapindex_name2id(MAP_PAYON)),-1,-1)) >= 0) {
- char_dat.last_point.map = j;
- char_dat.last_point.x = 87; // savepoint coordinates
+ char_dat.last_point.x = 87;
char_dat.last_point.y = 117;
} else if ((i = search_mapserver((j=mapindex_name2id(MAP_IZLUDE)),-1,-1)) >= 0) {
- char_dat.last_point.map = j;
- char_dat.last_point.x = 94; // savepoint coordinates
+ char_dat.last_point.x = 94;
char_dat.last_point.y = 103;
} else {
- // get first online server
- i = 0;
- for(j = 0; j < MAX_MAP_SERVERS; j++)
- if (server_fd[j] > 0 && server[j].map[0]) {
- i = j;
- ShowDebug("Map-server #%d found with a map: '%s'.\n", j, mapindex_id2name(server[j].map[0]));
- break;
- }
- // if no map-servers are connected, we send: server closed
- if (j == MAX_MAP_SERVERS) {
- WFIFOW(fd,0) = 0x81;
- WFIFOB(fd,2) = 1; // 01 = Server closed
- WFIFOSET(fd,3);
- break;
- }
+ ShowInfo("Connection Closed. No map server available that has a major city, and unable to find map-server for '%s'.\n", mapindex_id2name(char_dat.last_point.map));
+ WFIFOW(fd,0) = 0x81;
+ WFIFOB(fd,2) = 1; // 01 = Server closed
+ WFIFOSET(fd,3);
+ break;
}
+ ShowWarning("Unable to find map-server for '%s', sending to major city '%s'.\n", mapindex_id2name(char_dat.last_point.map), mapindex_id2name(j));
+ char_dat.last_point.map = j;
}
WFIFOW(fd, 0) =0x71;
WFIFOL(fd, 2) =char_dat.char_id;
diff --git a/src/map/script.c b/src/map/script.c index 707e87b16..c8319fb4b 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -12114,13 +12114,18 @@ int buildin_unitattack(struct script_state *st) { tbl = &sd->bl; if((bl = map_id2bl(id))){ - if (bl->type == BL_MOB) { - ((TBL_MOB *)bl)->state.killer = 1; - ((TBL_MOB *)bl)->target_id = tbl->id; - } else if(bl->type == BL_PC){ + switch (bl->type) { + case BL_PC: clif_parse_ActionRequest_sub(((TBL_PC *)bl), actiontype > 0?0x07:0x00, tbl->id, gettick()); push_val(st->stack,C_INT,1); return 0; + case BL_MOB: + ((TBL_MOB *)bl)->state.killer = 1; + ((TBL_MOB *)bl)->target_id = tbl->id; + break; + case BL_PET: + ((TBL_PET *)bl)->target_id = tbl->id; + break; } push_val(st->stack,C_INT,unit_walktobl(bl, tbl, 65025, 2)); } else { @@ -12160,28 +12165,7 @@ int buildin_unittalk(struct script_state *st) bl = map_id2bl(id); if(bl) { - switch(bl->type){ - case BL_MOB: - memcpy(message, ((TBL_MOB *)bl)->name, NAME_LENGTH); - break; - case BL_PC: - if(strlen(((TBL_PC *)bl)->fakename)>0) - memcpy(message, ((TBL_PC *)bl)->fakename, NAME_LENGTH); - else - memcpy(message, ((TBL_PC *)bl)->status.name, NAME_LENGTH); - break; - case BL_NPC: - memcpy(message, ((TBL_NPC *)bl)->name, NAME_LENGTH); - break; - case BL_HOM: - memcpy(message, ((TBL_HOM *)bl)->master->homunculus.name, NAME_LENGTH); - break; - case BL_PET: - memcpy(message, ((TBL_PET *)bl)->pet.name, NAME_LENGTH); - break; - default: - strcpy(message, "Unknown"); - } + memcpy(message, status_get_name(bl), NAME_LENGTH); strcat(message," : "); strncat(message,str, 228); //Prevent overflow possibility. [Skotlex] clif_message(bl, message); @@ -12210,27 +12194,12 @@ int buildin_unitdeadsit(struct script_state *st){ if((bl = map_id2bl(id))){ if(action > -1 && action < 4){ unsigned char buf[61] = ""; - switch(bl->type){ - case BL_MOB: - ((TBL_MOB *)bl)->vd->dead_sit = action; - break; - case BL_PC: - ((TBL_PC *)bl)->vd.dead_sit = action; - break; - case BL_NPC: - ((TBL_NPC *)bl)->vd->dead_sit = action; - break; - case BL_HOM: - ((TBL_HOM *)bl)->vd->dead_sit = action; - break; - case BL_PET: - ((TBL_PET *)bl)->vd.dead_sit = action; - break; - WBUFW(buf, 0) = 0x8a; - WBUFL(buf, 2) = bl->id; - WBUFB(buf,26) = (unsigned char)action; - clif_send(buf, 61, bl, AREA); - } + struct view_data *vd = status_get_viewdata(bl); + if (vd) vd->dead_sit = action; + WBUFW(buf, 0) = 0x8a; + WBUFL(buf, 2) = bl->id; + WBUFB(buf,26) = (unsigned char)action; + clif_send(buf, 61, bl, AREA); }else { ShowError("buildin_unitdeadsit: Invalid action.\n"); report_src(st); diff --git a/src/map/status.c b/src/map/status.c index 7a3d2c4eb..73bddae64 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -302,7 +302,6 @@ void initChangeTables(void) { set_sc(ST_CHASEWALK, SC_CHASEWALK, SI_BLANK, SCB_SPEED);
set_sc(ST_REJECTSWORD, SC_REJECTSWORD, SI_REJECTSWORD, SCB_NONE);
add_sc(ST_REJECTSWORD, SC_AUTOCOUNTER);
-// set_sc(CG_MOONLIT, SC_MOONLIT, SI_MOONLIT, SCB_NONE);
set_sc(CG_MARIONETTE, SC_MARIONETTE, SI_MARIONETTE, SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK);
set_sc(CG_MARIONETTE, SC_MARIONETTE2, SI_MARIONETTE2, SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK);
add_sc(LK_SPIRALPIERCE, SC_STOP);
@@ -3915,18 +3914,21 @@ const char * status_get_name(struct block_list *bl) nullpo_retr(0, bl);
switch (bl->type) {
case BL_MOB:
- return ((struct mob_data *)bl)->name;
+ return ((TBL_MOB*)bl)->name;
case BL_PC:
- return ((struct map_session_data *)bl)->status.name;
+ if(strlen(((TBL_PC *)bl)->fakename)>0)
+ return ((TBL_PC*)bl)->fakename;
+ return ((TBL_PC*)bl)->status.name;
case BL_PET:
- return ((struct pet_data *)bl)->pet.name;
+ return ((TBL_PET*)bl)->pet.name;
case BL_HOM:
- return ((struct homun_data *)bl)->master->homunculus.name;
+ if (((TBL_HOM*)bl)->master)
+ return ((TBL_HOM*)bl)->master->homunculus.name;
+ break;
case BL_NPC:
- return ((struct npc_data*)bl)->name;
- default:
- return "Unknown";
+ return ((TBL_NPC*)bl)->name;
}
+ return "Unknown";
}
/*==========================================
diff --git a/src/map/trade.c b/src/map/trade.c index 4d8f4200d..442566e49 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -230,9 +230,6 @@ int trade_check(struct map_session_data *sd, struct map_session_data *tsd) { return 0;
inventory2[i].amount += amount;
inventory[n].amount -= amount;
- //let's not make room, as pc_additem is done before pc_delitem, so it could lead to problems depending on order.
-// if (!inventory[n].amount)
-// malloc_set(&inventory[n], 0, sizeof(struct item));
break;
}
}
@@ -244,8 +241,6 @@ int trade_check(struct map_session_data *sd, struct map_session_data *tsd) { memcpy(&inventory2[i], &inventory[n], sizeof(struct item));
inventory2[i].amount = amount;
inventory[n].amount -= amount;
-// if (!inventory[n].amount)
-// malloc_set(&inventory[n], 0, sizeof(struct item));
}
}
amount = tsd->deal.item[trade_i].amount;
@@ -266,8 +261,6 @@ int trade_check(struct map_session_data *sd, struct map_session_data *tsd) { return 0;
inventory[i].amount += amount;
inventory2[n].amount -= amount;
-// if (!inventory2[n].amount)
-// malloc_set(&inventory2[n], 0, sizeof(struct item));
break;
}
}
@@ -278,8 +271,6 @@ int trade_check(struct map_session_data *sd, struct map_session_data *tsd) { memcpy(&inventory[i], &inventory2[n], sizeof(struct item));
inventory[i].amount = amount;
inventory2[n].amount -= amount;
-// if (!inventory2[n].amount)
-// malloc_set(&inventory2[n], 0, sizeof(struct item));
}
}
|