summaryrefslogtreecommitdiff
path: root/src/map/pc.c
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 /src/map/pc.c
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
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c52
1 files changed, 46 insertions, 6 deletions
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: