# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: /home/lighta/Documents/Myscript/RO/Servs/raclean
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: src/char/char.c
--- src/char/char.c Base (BASE)
+++ src/char/char.c Locally Modified (Based On LOCAL)
@@ -13,6 +13,7 @@
#include "../common/timer.h"
#include "../common/utils.h"
#include "../common/cli.h"
+#include "../common/random.h"
#include "int_guild.h"
#include "int_homun.h"
#include "int_mercenary.h"
@@ -29,6 +30,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
+#include <malloc.h>
#define CHAR_MAX_MSG 300
static char* msg_table[CHAR_MAX_MSG]; // Login Server messages_conf
@@ -132,8 +134,8 @@
char new_name[NAME_LENGTH];
char birthdate[10+1]; // YYYY-MM-DD
// Pincode system
- char pincode[4+1];
- uint16 pincode_seed;
+ char pincode[PINCODE_LENGTH+1];
+ uint32 pincode_seed;
time_t pincode_change;
uint16 pincode_try;
// Addon system
@@ -168,7 +170,7 @@
void pincode_sendstate( int fd, struct char_session_data* sd, uint16 state );
void pincode_notifyLoginPinUpdate( int account_id, char* pin );
void pincode_notifyLoginPinError( int account_id );
-void pincode_decrypt( unsigned long userSeed, char* pin );
+void pincode_decrypt( uint32 userSeed, char* pin );
int pincode_compare( int fd, struct char_session_data* sd, char* pin );
// Addon system
@@ -4275,9 +4277,7 @@
if( RFIFOREST(fd) < 10 )
return 0;
- if( RFIFOL(fd,2) != sd->account_id )
- break;
-
+ if( pincode_enabled && RFIFOL(fd,2) == sd->account_id )
pincode_check( fd, sd );
RFIFOSKIP(fd,10);
@@ -4288,14 +4288,13 @@
if( RFIFOREST(fd) < 6 )
return 0;
- if( RFIFOL(fd,2) != sd->account_id )
- break;
-
+ if( pincode_enabled && RFIFOL(fd,2) == sd->account_id ){
if( strlen( sd->pincode ) <= 0 ){
pincode_sendstate( fd, sd, PINCODE_NEW );
}else{
pincode_sendstate( fd, sd, PINCODE_ASK );
}
+ }
RFIFOSKIP(fd,6);
break;
@@ -4305,9 +4304,7 @@
if( RFIFOREST(fd) < 14 )
return 0;
- if( RFIFOL(fd,2) != sd->account_id )
- break;
-
+ if( pincode_enabled && RFIFOL(fd,2) == sd->account_id )
pincode_change( fd, sd );
RFIFOSKIP(fd,14);
@@ -4318,9 +4315,7 @@
if( RFIFOREST(fd) < 10 )
return 0;
- if( RFIFOL(fd,2) != sd->account_id )
- break;
-
+ if( pincode_enabled && RFIFOL(fd,2) == sd->account_id )
pincode_setnew( fd, sd );
RFIFOSKIP(fd,10);
@@ -4520,9 +4515,12 @@
//Pincode system
//------------------------------------------------
void pincode_check( int fd, struct char_session_data* sd ){
- char pin[5] = "\0\0\0\0";
- strncpy((char*)pin, (char*)RFIFOP(fd, 6), 4+1);
+ char pin[PINCODE_LENGTH+1];
+ memset(pin,0,PINCODE_LENGTH+1);
+
+ strncpy((char*)pin, (char*)RFIFOP(fd, 6), PINCODE_LENGTH);
+
pincode_decrypt(sd->pincode_seed, pin );
if( pincode_compare( fd, sd, pin ) ){
@@ -4546,27 +4544,33 @@
}
void pincode_change( int fd, struct char_session_data* sd ){
- char oldpin[5] = "\0\0\0\0";
- char newpin[5] = "\0\0\0\0";
+ char oldpin[PINCODE_LENGTH+1];
+ char newpin[PINCODE_LENGTH+1];
- strncpy(oldpin, (char*)RFIFOP(fd,6), 4+1);
+ memset(oldpin,0,PINCODE_LENGTH+1);
+ memset(newpin,0,PINCODE_LENGTH+1);
+
+ strncpy(oldpin, (char*)RFIFOP(fd,6), PINCODE_LENGTH);
pincode_decrypt(sd->pincode_seed,oldpin);
if( !pincode_compare( fd, sd, oldpin ) )
return;
- strncpy(newpin, (char*)RFIFOP(fd,10), 4+1);
+ strncpy(newpin, (char*)RFIFOP(fd,10), PINCODE_LENGTH);
pincode_decrypt(sd->pincode_seed,newpin);
pincode_notifyLoginPinUpdate( sd->account_id, newpin );
+ strncpy(sd->pincode, newpin, sizeof(newpin));
pincode_sendstate( fd, sd, PINCODE_PASSED );
}
void pincode_setnew( int fd, struct char_session_data* sd ){
- char newpin[5] = "\0\0\0\0";
+ char newpin[PINCODE_LENGTH+1];
- strncpy( newpin, (char*)RFIFOP(fd,6), 4+1 );
+ memset(newpin,0,PINCODE_LENGTH+1);
+
+ strncpy( newpin, (char*)RFIFOP(fd,6), PINCODE_LENGTH );
pincode_decrypt( sd->pincode_seed, newpin );
pincode_notifyLoginPinUpdate( sd->account_id, newpin );
@@ -4587,7 +4591,7 @@
void pincode_sendstate( int fd, struct char_session_data* sd, uint16 state ){
WFIFOHEAD(fd, 12);
WFIFOW(fd, 0) = 0x8b9;
- WFIFOL(fd, 2) = sd->pincode_seed = rand() % 0xFFFF;
+ WFIFOL(fd, 2) = sd->pincode_seed = rnd() % 0xFFFF;
WFIFOL(fd, 6) = sd->account_id;
WFIFOW(fd,10) = state;
WFIFOSET(fd,12);
@@ -4597,7 +4601,7 @@
WFIFOHEAD(login_fd,11);
WFIFOW(login_fd,0) = 0x2738;
WFIFOL(login_fd,2) = account_id;
- strncpy( (char*)WFIFOP(login_fd,6), pin, 5 );
+ strncpy( (char*)WFIFOP(login_fd,6), pin, PINCODE_LENGTH+1 );
WFIFOSET(login_fd,11);
}
@@ -4608,10 +4612,11 @@
WFIFOSET(login_fd,6);
}
-void pincode_decrypt( unsigned long userSeed, char* pin ){
+void pincode_decrypt( uint32 userSeed, char* pin ){
int i, pos;
char tab[10] = {0,1,2,3,4,5,6,7,8,9};
- unsigned long multiplier = 0x3498, baseSeed = 0x881234;
+ char *buf;
+ uint32 multiplier = 0x3498, baseSeed = 0x881234;
for( i = 1; i < 10; i++ ){
userSeed = baseSeed + userSeed * multiplier;
@@ -4623,11 +4628,13 @@
}
}
- for( i = 0; i < 4; i++ ){
- pin[i] = tab[pin[i]- '0'];
+ buf = (char *)malloc(sizeof(pin));
+ memset(buf,0,sizeof(pin));
+ for( i = 0; i < PINCODE_LENGTH; i++ ){
+ sprintf(buf+i,"%d",tab[pin[i] - '0']);
}
-
- sprintf(pin, "%d%d%d%d", pin[0], pin[1], pin[2], pin[3]);
+ strcpy(pin,buf);
+ free(buf);
}
//------------------------------------------------
@@ -5018,6 +5025,12 @@
guild_exp_rate = atoi(w2);
} else if (strcmpi(w1, "pincode_enabled") == 0) {
pincode_enabled = config_switch(w2);
+ #if PACKETVER < 20110309
+ if( pincode_enabled ) {
+ ShowWarning("pincode_enabled requires PACKETVER 20110309 or higher. Disabling...\n");
+ pincode_enabled = false;
+ }
+ #endif
} else if (strcmpi(w1, "pincode_changetime") == 0) {
pincode_changetime = atoi(w2)*60*60*24;
} else if (strcmpi(w1, "pincode_maxtry") == 0) {
Index: src/common/mmo.h
--- src/common/mmo.h Base (BASE)
+++ src/common/mmo.h Locally Modified (Based On LOCAL)
@@ -122,6 +122,8 @@
//For Map Names, which the client considers to be 16 in length including the .gat extension
#define MAP_NAME_LENGTH (11 + 1)
#define MAP_NAME_LENGTH_EXT (MAP_NAME_LENGTH + 4)
+//Pincode Length
+#define PINCODE_LENGTH 4
#define MAX_FRIENDS 40
#define MAX_MEMOPOINTS 3
Index: src/login/account.h
--- src/login/account.h Base (BASE)
+++ src/login/account.h Locally Modified (Based On LOCAL)
@@ -50,7 +50,7 @@
char lastlogin[24]; // date+time of last successful login
char last_ip[16]; // save of last IP of connection
char birthdate[10+1]; // assigned birth date (format: YYYY-MM-DD, default: 0000-00-00)
- char pincode[4+1]; // pincode system
+ char pincode[PINCODE_LENGTH+1]; // pincode system
time_t pincode_change; // (timestamp): last time of pincode change
int account_reg2_num;
struct global_reg account_reg2[ACCOUNT_REG2_NUM]; // account script variables (stored on login server)
Index: src/login/login.c
--- src/login/login.c Base (BASE)
+++ src/login/login.c Locally Modified (Based On LOCAL)
@@ -451,7 +451,6 @@
return 0;
else{
struct auth_node* node;
-
int account_id = RFIFOL(fd,2);
uint32 login_id1 = RFIFOL(fd,6);
uint32 login_id2 = RFIFOL(fd,10);
@@ -552,9 +551,11 @@
uint8 char_slots = 0;
int group_id = 0;
char birthdate[10+1] = "";
- char pincode[4+1] = "";
-
+ char pincode[PINCODE_LENGTH+1];
int account_id = RFIFOL(fd,2);
+
+ memset(pincode,0,PINCODE_LENGTH+1);
+
RFIFOSKIP(fd,6);
if( !accounts->load_num(accounts, &acc, account_id) )
Index: src/map/clif.c
--- src/map/clif.c Base (BASE)
+++ src/map/clif.c Locally Modified (Based On LOCAL)
@@ -5634,6 +5634,7 @@
}
}
}
+ dbi_destroy(iter);
}
db_destroy(channel->users);
if( channel->m ) {
Index: src/map/map.c
--- src/map/map.c Base (BASE)
+++ src/map/map.c Locally Modified (Based On LOCAL)
@@ -13,6 +13,7 @@
#include "../common/strlib.h"
#include "../common/utils.h"
#include "../common/cli.h"
+#include "../common/ers.h"
#include "map.h"
#include "path.h"
@@ -1485,8 +1486,7 @@
p = idb_ensure(nick_db, charid, create_charid2nick);
safestrncpy(p->nick, nick, sizeof(p->nick));
- while( p->requests )
- {
+ while( p->requests ) {
req = p->requests;
p->requests = req->next;
sd = map_charid2sd(req->charid);
@@ -1508,8 +1508,7 @@
if (!nick_db->remove(nick_db, db_i2key(charid), &data) || (p = db_data2ptr(&data)) == NULL)
return;
- while( p->requests )
- {
+ while( p->requests ) {
req = p->requests;
p->requests = req->next;
sd = map_charid2sd(req->charid);
@@ -1714,7 +1713,8 @@
}
if( sd->channel_count ) {
- for( i = 0; i < sd->channel_count; i++ ) {
+ uint8 ch_count = sd->channel_count;
+ for( i = 0; i < ch_count; i++ ) {
if( sd->channels[i] != NULL )
clif_chsys_left(sd->channels[i],sd);
}
@@ -2662,8 +2662,7 @@
return true;
}
-void map_iwall_get(struct map_session_data *sd)
-{
+void map_iwall_get(struct map_session_data *sd) {
struct iwall_data *iwall;
DBIterator* iter;
int16 x1, y1;
@@ -2673,13 +2672,11 @@
return;
iter = db_iterator(iwall_db);
- for( iwall = dbi_first(iter); dbi_exists(iter); iwall = dbi_next(iter) )
- {
+ for( iwall = dbi_first(iter); dbi_exists(iter); iwall = dbi_next(iter) ) {
if( iwall->m != sd->bl.m )
continue;
- for( i = 0; i < iwall->size; i++ )
- {
+ for( i = 0; i < iwall->size; i++ ) {
map_iwall_nextxy(iwall->x, iwall->y, iwall->dir, i, &x1, &y1);
clif_changemapcell(sd->fd, iwall->m, x1, y1, map_getcell(iwall->m, x1, y1, CELL_GETTYPE), SELF);
}
@@ -2695,8 +2692,7 @@
if( (iwall = (struct iwall_data *)strdb_get(iwall_db, wall_name)) == NULL )
return; // Nothing to do
- for( i = 0; i < iwall->size; i++ )
- {
+ for( i = 0; i < iwall->size; i++ ) {
map_iwall_nextxy(iwall->x, iwall->y, iwall->dir, i, &x1, &y1);
map_setcell(iwall->m, x1, y1, CELL_SHOOTABLE, true);
@@ -3186,6 +3182,9 @@
runflag = 0;
}
}
+ else if( strcmpi("ers_report", type) == 0 ){
+ ers_report();
+ }
else if( strcmpi("help", type) == 0 )
{
ShowInfo("To use GM commands:\n");
@@ -3751,7 +3750,6 @@
rnd_init();
map_config_read(MAP_CONF_NAME);
- /* only temporary until sirius's datapack patch is complete */
// loads npcs
map_reloadnpc(false);
Index: src/map/script.c
--- src/map/script.c Base (BASE)
+++ src/map/script.c Locally Modified (Based On LOCAL)
@@ -4790,8 +4790,10 @@
{
const char* name = reference_getname(data);
if( name[0] == '.' ) {
+ if(!ref){
ref = (struct DBMap**)aCalloc(sizeof(struct DBMap*), 1);
ref[0] = (name[1] == '@' ? st->stack->var_function : st->script->script_vars);
+ }
data->ref = ref;
}
}