Skip to content
Permalink
Browse files
Adding banking support
  • Loading branch information
lighta committed Nov 5, 2013
1 parent cd3cb9f commit 1290826be233d3a67a8ead585db1d46b3bf5053f
@@ -17,4 +17,8 @@ feature.search_stores: on

// Atcommand suggestions (Note 1)
// If one type incomplete atcommand, it will suggest the complete ones.
feature.atcommand_suggestions: off
feature.atcommand_suggestions: off

// Banking (Note 1)
// Requires: 2013-07-24aRagexe or later
feature.banking: on
@@ -103,6 +103,7 @@ mercenary_db: mercenary
mercenary_owner_db: mercenary_owner
elemental_db: elemental
ragsrvinfo_db: ragsrvinfo
skillcooldown_db: skillcooldown

// Map Database Tables
item_db_db: item_db
@@ -28,6 +28,7 @@
// 0x10000 - (X) Log all other transactions (rentals expiring/inserting cards/items removed by item_check/
// rings deleted by divorce/pet egg (un)hatching/pet armor (un)equipping/Weapon Refine skill/Remove Trap skill)
// 0x20000 - ($) Log cash transactions
// 0x40000 - (K) Log account bank transactions
// Example: Log trades+vending+script items+created items: 1+2+32+1024 = 1059
// Please note that moving items from inventory to cart and back is not logged by design.
enable_logs: 0xFFFFF
@@ -101,11 +101,12 @@ minsave_time: 100
// 16: After successfully sending a mail with attachment
// 32: After successfully submitting an item for auction
// 64: After successfully get/delete/complete a quest
// 128: After every bank transaction (deposit/withdraw)
// NOTE: These settings decrease the chance of dupes/lost items when there's a
// server crash at the expense of increasing the map/char server lag. If your
// server rarely crashes, but experiences interserver lag, you may want to set
// these off.
save_settings: 127
save_settings: 255

// Message of the day file, when a character logs on, this message is displayed.
motd_txt: conf/motd.txt
@@ -1493,5 +1493,9 @@
1490: Item types on your autoloottype list:
1491: Your autoloottype list has been reset.

//Banking
1492: You can't withdraw that much money
1493: Banking is disabled

//Custom translations
//import: conf/msg_conf/import/map_msg_eng_conf.txt
@@ -2190,3 +2190,45 @@ packet_ver: 44
0x0863,26,friendslistadd,2
0x088A,5,hommenu,2:4
0x095B,36,storagepassword,2:4:20
0x09A6,12,ZC_BANKING_CHECK,2:10
0x09A7,10,bankdeposit,2:6
0x09A8,16,ZC_ACK_BANKING_DEPOSIT,2:4:12
0x09A9,10,bankwithdrawal,2:6
0x09AA,16,ZC_ACK_BANKING_WITHDRAW,2:4:12
0x09AB,6,bankcheck,2
0x09B6,6,bankopen,2
0x09B7,4,ZC_ACK_OPEN_BANKING,2
0x09B8,6,bankclose,2
0x09B9,4,ZC_ACK_CLOSE_BANKING,2

//2013-08-07Ragexe (Shakto)
packet_ver: 45
0x0369,7,actionrequest,2:6
0x083C,10,useskilltoid,2:4:6
0x0437,5,walktoxy,2
0x035F,6,ticksend,2
0x0202,5,changedir,2:4
0x07E4,6,takeitem,2
0x0362,6,dropitem,2:4
0x07EC,8,movetokafra,2:4
0x0364,8,movefromkafra,2:4
0x0438,10,useskilltopos,2:4:6:8
0x0366,90,useskilltoposinfo,2:4:6:8:10
0x096A,6,getcharnamerequest,2
0x0368,6,solvecharname,2
0x0838,12,searchstoreinfolistitemclick,2:6:10
0x0835,2,searchstoreinfonextpage,0
0x0819,-1,searchstoreinfo,2:4:5:9:13:14:15
0x0811,-1,reqtradebuyingstore,2:4:8:12
0x0360,6,reqclickbuyingstore,2
0x0817,2,reqclosebuyingstore,0
0x0815,-1,reqopenbuyingstore,2:4:8:9:89
0x0365,18,bookingregreq,2:4:6
// 0x363,8 CZ_JOIN_BATTLE_FIELD
0x0281,-1,itemlistwindowselected,2:4:8:12
0x022D,19,wanttoconnection,2:6:10:14:18
0x0802,26,partyinvite2,2
// 0x436,4 CZ_GANGSI_RANK
0x023B,26,friendslistadd,2
0x0361,5,hommenu,2:4
0x0887,36,storagepassword,2:4:20
@@ -459,6 +459,7 @@ CREATE TABLE IF NOT EXISTS `login` (
`character_slots` tinyint(3) unsigned NOT NULL default '0',
`pincode` varchar(4) NOT NULL DEFAULT '',
`pincode_change` int(11) unsigned NOT NULL DEFAULT '0',
`bank_vault` BIGINT(64) NOT NULL DEFAULT '0',
PRIMARY KEY (`account_id`),
KEY `name` (`userid`)
) ENGINE=MyISAM AUTO_INCREMENT=2000000;
@@ -0,0 +1 @@
ALTER TABLE `login` ADD `bank_vault` BIGINT( 64 ) NOT NULL DEFAULT '0';
@@ -143,6 +143,7 @@ struct char_session_data {
time_t pincode_change;
uint16 pincode_try;
// Addon system
int bank_vault;
unsigned int char_moves[MAX_CHARS]; // character moves left
};

@@ -189,6 +190,12 @@ bool char_moves_unlimited = false;
void moveCharSlot( int fd, struct char_session_data* sd, unsigned short from, unsigned short to );
void moveCharSlotReply( int fd, struct char_session_data* sd, unsigned short index, short reason );

int loginif_BankingReq(int32 account_id, int8 type, int32 data);
int loginif_parse_BankingAck(int fd);
int mapif_BankingAck(int32 account_id, int32 bank_vault);
int mapif_parse_UpdBankInfo(int fd);
int mapif_parse_ReqBankInfo(int fd);

//Custom limits for the fame lists. [Skotlex]
int fame_list_size_chemist = MAX_FAME_LIST;
int fame_list_size_smith = MAX_FAME_LIST;
@@ -552,7 +559,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
} else
strcat(save_status, " status");
}

//Values that will seldom change (to speed up saving)
if (
(p->hair != cp->hair) || (p->hair_color != cp->hair_color) || (p->clothes_color != cp->clothes_color) ||
@@ -591,7 +598,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
else
errors++;
}

//memo points
if( memcmp(p->memo_point, cp->memo_point, sizeof(p->memo_point)) )
{
@@ -2146,6 +2153,83 @@ static void char_auth_ok(int fd, struct char_session_data *sd)
int send_accounts_tologin(int tid, unsigned int tick, int id, intptr_t data);
void mapif_server_reset(int id);

/*
* HA 0x2740<aid>L <type>B <data>L
* type:
* 0 = select
* 1 = update
*/
int loginif_BankingReq(int32 account_id, int8 type, int32 data){
if (login_fd > 0 && session[login_fd] && !session[login_fd]->flag.eof){
WFIFOHEAD(login_fd,11);
WFIFOW(login_fd,0) = 0x2740;
WFIFOL(login_fd,2) = account_id;
WFIFOB(login_fd,6) = type;
WFIFOL(login_fd,7) = data;
WFIFOSET(login_fd,11);
return 1;
}
return 0;
}

/*
* Received the banking data from login and transmit it to all map-serv
* AH 0x2741<aid>L <bank_vault>L <not_fw>B
* HZ 0x2b29 <aid>L <bank_vault>L
*/
int loginif_parse_BankingAck(int fd){
if (RFIFOREST(fd) < 11)
return 0;
uint32 aid = RFIFOL(fd,2);
int32 bank_vault = RFIFOL(fd,6);
char not_fw = RFIFOB(fd,10);
RFIFOSKIP(fd,11);

if(!not_fw) mapif_BankingAck(aid, bank_vault);
return 1;
}

//HZ 0x2b29 <aid>L <bank_vault>L
int mapif_BankingAck(int32 account_id, int32 bank_vault){
unsigned char buf[14];
WBUFW(buf,0) = 0x2b29;
WBUFL(buf,2) = account_id;
WBUFL(buf,6) = bank_vault;
mapif_sendall(buf, 10); //inform all maps-attached
return 1;
}

/*
* Receive a map request to save banking
* Fowarding it to login-serv
* ZH 0x2b28 <aid>L <money>L
* HA 0x2740<aid>L <type>B <money>L
*/
int mapif_parse_UpdBankInfo(int fd){
if( RFIFOREST(fd) < 10 )
return 0;
uint32 aid = RFIFOL(fd,2);
int money = RFIFOL(fd,6);
RFIFOSKIP(fd,10);
loginif_BankingReq(aid, 2, money);
return 1;
}

/*
* Receive a map request to get banking info
* Fowarding it to login-serv
* ZH 0x2b2a <aid>L
* HA 0x2740<aid>L <type>B <money>L
*/
int mapif_parse_ReqBankInfo(int fd){
if( RFIFOREST(fd) < 6 )
return 0;
uint32 aid = RFIFOL(fd,2);
RFIFOSKIP(fd,6);
loginif_BankingReq(aid, 1, 0);
return 1;
}


/// Resets all the data.
void loginif_reset(void)
@@ -2230,6 +2314,7 @@ int parse_fromlogin(int fd) {

switch( command )
{
case 0x2741: loginif_parse_BankingAck(fd); break;

// acknowledgement of connect-to-loginserver request
case 0x2711:
@@ -2289,7 +2374,7 @@ int parse_fromlogin(int fd) {
break;

case 0x2717: // account data
if (RFIFOREST(fd) < 72)
if (RFIFOREST(fd) < 76)
return 0;

// find the authenticated session with this account id
@@ -2309,6 +2394,7 @@ int parse_fromlogin(int fd) {
safestrncpy(sd->birthdate, (const char*)RFIFOP(fd,52), sizeof(sd->birthdate));
safestrncpy(sd->pincode, (const char*)RFIFOP(fd,63), sizeof(sd->pincode));
sd->pincode_change = (time_t)RFIFOL(fd,68);
sd->bank_vault = RFIFOL(fd,72);
ARR_FIND( 0, ARRAYLENGTH(server), server_id, server[server_id].fd > 0 && server[server_id].map[0] );
// continued from char_auth_ok...
if( server_id == ARRAYLENGTH(server) || //server not online, bugreport:2359
@@ -2355,7 +2441,7 @@ int parse_fromlogin(int fd) {
#endif
}
}
RFIFOSKIP(fd,72);
RFIFOSKIP(fd,76);
break;

// login-server alive packet
@@ -3579,6 +3665,9 @@ int parse_frommap(int fd)
RFIFOSKIP(fd, RFIFOW(fd,2) );/* skip this packet */
}
break;

case 0x2b28: mapif_parse_UpdBankInfo(fd); break;
case 0x2b2a: mapif_parse_ReqBankInfo(fd); break;

default:
{
@@ -47,7 +47,7 @@
// 20120307 - 2012-03-07aRagexeRE+ - 0x970

#ifndef PACKETVER
#define PACKETVER 20120410
#define PACKETVER 20130724
//#define PACKETVER 20130320
//#define PACKETVER 20111116
#endif
@@ -79,6 +79,7 @@
//Max amount of a single stacked item
#define MAX_AMOUNT 30000
#define MAX_ZENY 1000000000
#define MAX_BANK_ZENY SINT32_MAX
#define MAX_FAME 1000000000
#define MAX_CART 100
#define MAX_SKILL 5020
@@ -351,6 +352,7 @@ struct mmo_charstatus {

unsigned int base_exp,job_exp;
int zeny;
int bank_vault;

short class_;
unsigned int status_point,skill_point;
@@ -53,6 +53,7 @@ struct mmo_account
char pincode[PINCODE_LENGTH+1]; // pincode system
time_t pincode_change; // (timestamp): last time of pincode change
int account_reg2_num;
int bank_vault;
struct global_reg account_reg2[ACCOUNT_REG2_NUM]; // account script variables (stored on login server)
};

4 comments on commit 1290826

@lighta
Copy link
Member Author

@lighta lighta commented on 1290826 Nov 5, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok sorry about the log message, wasn,t exactly what I expecting.
Thx to Hercule and akinari for implementing this.

note:
-Fix default name for skillcooldown_db
-Test multiclient support for outgoing packet
-Add few missing documentation of used packet in chrif

@MishimaHaruna
Copy link

@MishimaHaruna MishimaHaruna commented on 1290826 Nov 6, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bank_vault in the login table? O.o

What happens if multiple character servers connect to the same login server? (I've seen that scenario pretty often with testservers sharing the same login as the main server, or high+lowrate servers sharing the same login)

@lighta
Copy link
Member Author

@lighta lighta commented on 1290826 Nov 7, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ye but that arguments could be made in other way around. bank_vault in chartable; what if they wanted to share ?
Fact is that we already have some shared variable handle in login. group_id, all #var, charactere_slots. So looking at this I think it's more coherent to put them in logging. or you could move all those into account_table wich is readen by char cause we could very well say that testserv need a different group_id then mainserv, or even number of char allowed to create (charslot).

In short on char_table it could be ok if you want separation but you already have some var in that case so it's more coherent like this.

@cydh
Copy link
Contributor

@cydh cydh commented on 1290826 Sep 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I miss this conversation.
but the problem is not that @lighta you out bank vault pure in login table that handled directly by login-server
you have many server with various rates and custom that different each server. you make money on high-rate (that easy to get money) then throw it on Bank, and withdraw from low-rate server (I hardly find money at this server!). it's ruining server economy.

group_id, everyone know and no issue with this and character_slots server owner know how to use this, and doesn't bother at all for multiple char-servers.

uhh what, #var login-server? Did u meant ##var?

Please sign in to comment.