Added pincode state tracking (#8412)

Fixes #6595

Thanks to @Danil0v3s
This commit is contained in:
Lemongrass3110 2024-06-11 21:50:16 +02:00 committed by GitHub
parent 0d3550e7ea
commit 6fdaac4a75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 42 additions and 0 deletions

View File

@ -266,6 +266,7 @@ struct char_session_data {
uint32 pincode_seed;
time_t pincode_change;
uint16 pincode_try;
bool pincode_correct;
// Addon system
unsigned int char_moves[MAX_CHARS]; // character moves left
uint8 isvip;

View File

@ -182,6 +182,7 @@ int chclif_parse_pincode_check( int fd, struct char_session_data* sd ){
}
if( char_pincode_compare( fd, sd, pin ) ){
sd->pincode_correct = true;
chclif_pincode_sendstate( fd, sd, PINCODE_PASSED );
}
return 1;
@ -322,6 +323,7 @@ int chclif_parse_pincode_setnew( int fd, struct char_session_data* sd ){
if( pincode_allowed(newpin) ){
chlogif_pincode_notifyLoginPinUpdate( sd->account_id, newpin );
strncpy( sd->pincode, newpin, sizeof( newpin ) );
sd->pincode_correct = true;
chclif_pincode_sendstate( fd, sd, PINCODE_PASSED );
}else{
@ -757,6 +759,7 @@ int chclif_parse_reqtoconnect(int fd, struct char_session_data* sd,uint32 ipl){
sd->login_id2 = login_id2;
sd->sex = sex;
sd->auth = false; // not authed yet
sd->pincode_correct = false; // not entered pincode correctly yet
// send back account_id
WFIFOHEAD(fd,4);
@ -1569,6 +1572,44 @@ int chclif_parse(int fd) {
unsigned short cmd;
cmd = RFIFOW(fd,0);
#if PACKETVER_SUPPORTS_PINCODE
// If the pincode system is enabled
if( charserv_config.pincode_config.pincode_enabled ){
switch( cmd ){
// Connect of player
case 0x65:
// Client keep-alive packet (every 12 seconds)
case 0x187:
// Checks the entered pin
case 0x8b8:
// Request for PIN window
case 0x8c5:
// Request character list
case 0x9a1:
// Connect of map-server
case 0x2af8:
break;
// Before processing any other packets, do a few checks
default:
// If the pincode was entered correctly
if( sd->pincode_correct ){
break;
}
// If no pincode is set (yet)
if( strlen( sd->pincode ) <= 0 ){
break;
}
// The pincode was not entered correctly, yet the player (=bot) tried to send a different packet => Goodbye!
set_eof( fd );
return 0;
}
}
#endif
switch( cmd ) {
case 0x65: next=chclif_parse_reqtoconnect(fd,sd,ipl); break;
// char select