summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-10-11 19:49:55 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-10-11 19:49:55 +0000
commit75d8e3d12caacd6a538982bb5c31ff1ce6f34527 (patch)
tree1a2cd9402304e6b67d6db9ab71ad163d23190558 /src/map
parent47d2e59ecf47d9f4d68458eb95e4a05fee06d8fb (diff)
downloadhercules-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/map')
-rw-r--r--src/map/script.c63
-rw-r--r--src/map/status.c18
-rw-r--r--src/map/trade.c9
3 files changed, 26 insertions, 64 deletions
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));
}
}