summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-05-14 03:15:51 +0000
committerai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-05-14 03:15:51 +0000
commit7a8dc0434b420af441041e2ec2fe32ee614c4555 (patch)
treea0f149b4b0565d1f3ee93ccf4c0a5a1fdb8b717c
parent851f1599bd54aad53efa05863a7b5a5441972b54 (diff)
downloadhercules-7a8dc0434b420af441041e2ec2fe32ee614c4555.tar.gz
hercules-7a8dc0434b420af441041e2ec2fe32ee614c4555.tar.bz2
hercules-7a8dc0434b420af441041e2ec2fe32ee614c4555.tar.xz
hercules-7a8dc0434b420af441041e2ec2fe32ee614c4555.zip
* Random accumulated bits and pieces.
- Added checks/warnings to pc_paycash and pc_getcash (follow up to r12264). - Added missing packet_db.txt and packet length table entries for packet 0x0859 (follow up to r14799). - Added set of map_id2xx wrappers for map_id2bl for most common map objects, which return NULL when the bl-type is not the expected one (also updated map_id2nd to behave this way). - Fixed missing ',' in mob_skill_db.txt example (follow up to r14270). - Updated mapcache with recent maps (up to que_lhz). - Functions 'msg_txt' and 'job_name' now return a const pointer. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14813 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt8
-rw-r--r--conf/maps_athena.conf18
-rw-r--r--db/map_cache.datbin1940566 -> 1952236 bytes
-rw-r--r--db/map_index.txt10
-rw-r--r--db/mob_skill_db.txt2
-rw-r--r--db/packet_db.txt1
-rw-r--r--src/map/atcommand.c8
-rw-r--r--src/map/atcommand.h2
-rw-r--r--src/map/clif.c5
-rw-r--r--src/map/map.c26
-rw-r--r--src/map/map.h3
-rw-r--r--src/map/pc.c52
-rw-r--r--src/map/pc.h2
-rw-r--r--src/map/script.c2
14 files changed, 120 insertions, 19 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 75c1300ca..a8cbfccdf 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -1,5 +1,13 @@
Date Added
+2011/05/13
+ * Random accumulated bits and pieces. [Ai4rei]
+ - Added checks/warnings to pc_paycash and pc_getcash (follow up to r12264).
+ - Added missing packet_db.txt and packet length table entries for packet 0x0859 (follow up to r14799).
+ - Added set of map_id2xx wrappers for map_id2bl for most common map objects, which return NULL when the bl-type is not the expected one (also updated map_id2nd to behave this way).
+ - Fixed missing ',' in mob_skill_db.txt example (follow up to r14270).
+ - Updated mapcache with recent maps (up to que_lhz).
+ - Functions 'msg_txt' and 'job_name' now return a const pointer.
2011/05/08
* Script command 'query_logsql' now throws a warning when SQL logs are disabled (related r11892). [Ai4rei]
* Updated/revised description of instance-related script commands (bugreport:4880). [Ai4rei]
diff --git a/conf/maps_athena.conf b/conf/maps_athena.conf
index 514a642a7..384802628 100644
--- a/conf/maps_athena.conf
+++ b/conf/maps_athena.conf
@@ -679,6 +679,10 @@ map: tha_t12
map: auction_01
map: auction_02
+// ???
+// -- 2005-12-06gdata_k.gpf
+alde_tt03
+
// --- Garden City Hugel / Kiehl ---
// -- 2005-12-20sdata_k.gpf --
map: hugel
@@ -989,6 +993,20 @@ map: iz_dun05
// -- 2010-12-01data_x.gpf
map: evt_mobroom
+// ???
+map: dic_dun03
+//map: mjolnir_04_1
+//map: evt_swar_b
+//map: evt_swar_r
+//map: evt_swar_s
+//map: evt_swar_t
+
+// Lighthalzen Dungeon F4, Wolfchev's Laboratory
+// -- 2011-03-16rdata_x.gpf
+map: 1@lhz
+map: lhz_dun04
+map: que_lhz
+
//------------------------- Clone Maps ---------------------------
//------------------------- Extra Maps ---------------------------
diff --git a/db/map_cache.dat b/db/map_cache.dat
index de5e23957..6f034c6c7 100644
--- a/db/map_cache.dat
+++ b/db/map_cache.dat
Binary files differ
diff --git a/db/map_index.txt b/db/map_index.txt
index d120516e9..f30553b19 100644
--- a/db/map_index.txt
+++ b/db/map_index.txt
@@ -810,6 +810,16 @@ mal_dun01
1@cash
iz_dun05
evt_mobroom
+alde_tt03
+dic_dun03
+//mjolnir_04_1
+//evt_swar_b
+//evt_swar_r
+//evt_swar_s
+//evt_swar_t
+1@lhz
+lhz_dun04
+que_lhz
// Only add maps under this line if they are not standard maps!
diff --git a/db/mob_skill_db.txt b/db/mob_skill_db.txt
index 81de7614f..6bba81d28 100644
--- a/db/mob_skill_db.txt
+++ b/db/mob_skill_db.txt
@@ -2,7 +2,7 @@
//
//MOB_ID,dummy value (info only),STATE,SKILL_ID,SKILL_LV,rate (10000 = 100%),casttime,delay,cancelable,target,condition type,condition value,val1,val2,val3,val4,val5,emotion,chat
//Example
-//1001,Poring@TF_POISON,attack,52,3,100,1500,10000,no,target,always,0,,,,,7
+//1001,Poring@TF_POISON,attack,52,3,100,1500,10000,no,target,always,0,,,,,7,
//
//rate refers to the chance of the skill being casted when the condition is fulfilled.
//delay is the time in milliseconds that has to be pass before recasting the same skill.
diff --git a/db/packet_db.txt b/db/packet_db.txt
index dc5b72346..f00c6d08e 100644
--- a/db/packet_db.txt
+++ b/db/packet_db.txt
@@ -1603,6 +1603,7 @@ packet_ver: 26
0x0856,-1
0x0857,-1
0x0858,-1
+0x0859,-1
//Add new packets here
//packet_ver: 27
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 80f0c84f3..459a6a734 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -89,7 +89,7 @@ int lowtohigh_compare (const void * a, const void * b)
//-----------------------------------------------------------
// Return the message string of the specified number by [Yor]
//-----------------------------------------------------------
-char* msg_txt(int msg_number)
+const char* msg_txt(int msg_number)
{
if (msg_number >= 0 && msg_number < MAX_MSG &&
msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
@@ -5753,7 +5753,7 @@ ACMD_FUNC(skilltree)
struct map_session_data *pl_sd = NULL;
int skillnum;
int meets, j, c=0;
- char target[NAME_LENGTH], *tbl;
+ char target[NAME_LENGTH];
struct skill_tree_entry *ent;
nullpo_retr(-1, sd);
@@ -5771,9 +5771,7 @@ ACMD_FUNC(skilltree)
c = pc_calc_skilltree_normalize_job(pl_sd);
c = pc_mapid2jobid(c, pl_sd->status.sex);
- tbl = job_name(c);
-
- sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)", tbl, pc_checkskill(pl_sd, 1));
+ sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)", job_name(c), pc_checkskill(pl_sd, 1));
clif_displaymessage(fd, atcmd_output);
ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skillnum );
diff --git a/src/map/atcommand.h b/src/map/atcommand.h
index 37ce87ca3..5456bc348 100644
--- a/src/map/atcommand.h
+++ b/src/map/atcommand.h
@@ -41,7 +41,7 @@ int atcommand_killmonster(const int fd, struct map_session_data* sd, const char*
#define MAX_MSG 1000
extern char* msg_table[MAX_MSG];
-char* msg_txt(int msg_number);
+const char* msg_txt(int msg_number);
int msg_config_read(const char* cfgName);
void do_final_msg(void);
diff --git a/src/map/clif.c b/src/map/clif.c
index a1b617b83..eeb9f7532 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -9692,7 +9692,8 @@ void clif_parse_ChatLeave(int fd, struct map_session_data* sd)
//0:
static void clif_noask_sub(struct map_session_data *src, struct map_session_data *target, int type)
{
- char *msg, output[256];
+ const char* msg;
+ char output[256];
// Your request has been rejected by autoreject option.
msg = msg_txt(392);
clif_disp_onlyself(src, msg, strlen(msg));
@@ -15029,7 +15030,7 @@ static int packetdb_readdb(void)
0, 0, 0, 0, 0, -1, -1, 3, 2, 66, 5, 2, 12, 6, 0, 0,
//#0x0840
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
diff --git a/src/map/map.c b/src/map/map.c
index 12c805ef3..762cf1446 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -1659,8 +1659,30 @@ struct mob_data * map_id2md(int id)
struct npc_data * map_id2nd(int id)
{// just a id2bl lookup because there's no npc_db
- if (id <= 0) return NULL;
- return (struct npc_data*)map_id2bl(id);
+ struct block_list* bl = map_id2bl(id);
+
+ return BL_CAST(BL_NPC, bl);
+}
+
+struct homun_data* map_id2hd(int id)
+{
+ struct block_list* bl = map_id2bl(id);
+
+ return BL_CAST(BL_HOM, bl);
+}
+
+struct mercenary_data* map_id2mc(int id)
+{
+ struct block_list* bl = map_id2bl(id);
+
+ return BL_CAST(BL_MER, bl);
+}
+
+struct chat_data* map_id2cd(int id)
+{
+ struct block_list* bl = map_id2bl(id);
+
+ return BL_CAST(BL_CHAT, bl);
}
/// Returns the nick of the target charid or NULL if unknown (requests the nick to the char server).
diff --git a/src/map/map.h b/src/map/map.h
index 8e0c11a03..456384360 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -584,6 +584,9 @@ struct map_session_data* map_charid2sd(int charid);
struct map_session_data * map_id2sd(int id);
struct mob_data * map_id2md(int id);
struct npc_data * map_id2nd(int id);
+struct homun_data* map_id2hd(int id);
+struct mercenary_data* map_id2mc(int id);
+struct chat_data* map_id2cd(int id);
struct block_list * map_id2bl(int id);
#define map_id2index(id) map[(id)].index
diff --git a/src/map/pc.c b/src/map/pc.c
index db42fdeca..4371b1276 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -3263,11 +3263,31 @@ int pc_payzeny(struct map_session_data *sd,int zeny)
void pc_paycash(struct map_session_data *sd, int price, int points)
{
char output[128];
- int cash = price - points;
+ int cash;
nullpo_retv(sd);
- pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints - cash);
- pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints - points);
+ if( price < 0 || points < 0 )
+ {
+ ShowError("pc_paycash: Paying negative points (price=%d, points=%d, account_id=%d, char_id=%d).\n", price, points, sd->status.account_id, sd->status.char_id);
+ return;
+ }
+
+ if( points > price )
+ {
+ ShowWarning("pc_paycash: More kafra points provided than needed (price=%d, points=%d, account_id=%d, char_id=%d).\n", price, points, sd->status.account_id, sd->status.char_id);
+ points = price;
+ }
+
+ cash = price-points;
+
+ if( sd->cashPoints < cash || sd->kafraPoints < points )
+ {
+ ShowError("pc_paycash: Not enough points (cash=%d, kafra=%d) to cover the price (cash=%d, kafra=%d) (account_id=%d, char_id=%d).\n", sd->cashPoints, sd->kafraPoints, cash, points, sd->status.account_id, sd->status.char_id);
+ return;
+ }
+
+ pc_setaccountreg(sd, "#CASHPOINTS", sd->cashPoints-cash);
+ pc_setaccountreg(sd, "#KAFRAPOINTS", sd->kafraPoints-points);
if( battle_config.cashshop_show_points )
{
@@ -3283,7 +3303,13 @@ void pc_getcash(struct map_session_data *sd, int cash, int points)
if( cash > 0 )
{
- pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints + cash);
+ if( cash > MAX_ZENY-sd->cashPoints )
+ {
+ ShowWarning("pc_getcash: Cash point overflow (cash=%d, have cash=%d, account_id=%d, char_id=%d).\n", cash, sd->cashPoints, sd->status.account_id, sd->status.char_id);
+ cash = MAX_ZENY-sd->cashPoints;
+ }
+
+ pc_setaccountreg(sd, "#CASHPOINTS", sd->cashPoints+cash);
if( battle_config.cashshop_show_points )
{
@@ -3291,10 +3317,20 @@ void pc_getcash(struct map_session_data *sd, int cash, int points)
clif_disp_onlyself(sd, output, strlen(output));
}
}
+ else if( cash < 0 )
+ {
+ ShowError("pc_getcash: Obtaining negative cash points (cash=%d, account_id=%d, char_id=%d).\n", cash, sd->status.account_id, sd->status.char_id);
+ }
if( points > 0 )
{
- pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints + points);
+ if( points > MAX_ZENY-sd->kafraPoints )
+ {
+ ShowWarning("pc_getcash: Kafra point overflow (points=%d, have points=%d, account_id=%d, char_id=%d).\n", points, sd->kafraPoints, sd->status.account_id, sd->status.char_id);
+ points = MAX_ZENY-sd->kafraPoints;
+ }
+
+ pc_setaccountreg(sd, "#KAFRAPOINTS", sd->kafraPoints+points);
if( battle_config.cashshop_show_points )
{
@@ -3302,6 +3338,10 @@ void pc_getcash(struct map_session_data *sd, int cash, int points)
clif_disp_onlyself(sd, output, strlen(output));
}
}
+ else if( points < 0 )
+ {
+ ShowError("pc_getcash: Obtaining negative kafra points (points=%d, account_id=%d, char_id=%d).\n", points, sd->status.account_id, sd->status.char_id);
+ }
}
/*==========================================
@@ -4608,7 +4648,7 @@ int pc_mapid2jobid(unsigned short class_, int sex)
/*====================================================
* This function return the name of the job (by [Yor])
*----------------------------------------------------*/
-char* job_name(int class_)
+const char* job_name(int class_)
{
switch (class_) {
case JOB_NOVICE:
diff --git a/src/map/pc.h b/src/map/pc.h
index 0473df3a9..beae8a0a3 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -727,7 +727,7 @@ int pc_candrop(struct map_session_data *sd,struct item *item);
int pc_jobid2mapid(unsigned short b_class); // Skotlex
int pc_mapid2jobid(unsigned short class_, int sex); // Skotlex
-char * job_name(int class_);
+const char * job_name(int class_);
struct skill_tree_entry {
short id;
diff --git a/src/map/script.c b/src/map/script.c
index 6b1366f07..39daede0e 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -4780,7 +4780,7 @@ BUILDIN_FUNC(jobchange)
BUILDIN_FUNC(jobname)
{
int class_=script_getnum(st,2);
- script_pushconststr(st,job_name(class_));
+ script_pushconststr(st, (char*)job_name(class_));
return 0;
}