- removed the timer heap correction code when the timers overflow since Flavio points out that it is not needed.

- Modified a bit the changesex code so you get saved and quit before changing your sex rather than afterwards.
- Cleaned up #changesex
- Signum Crucis now works on bosses.
- party_recv_data will not set the sd pointer for not-yet-authed characters.


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11867 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
skotlex 2007-12-07 08:44:52 +00:00
parent e5554e3fae
commit e823c2e3eb
8 changed files with 69 additions and 109 deletions

View File

@ -3,6 +3,13 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2007/12/07
* removed the timer heap correction code when the timers overflow since
Flavio points out that it is not needed.
* Modified a bit the changesex code so you get saved and quit before
changing your sex rather than afterwards.
* Cleaned up #changesex
* Signum Crucis now works on bosses. [Skotlex]
2007/12/06 2007/12/06
* Removed the attempts to recover from invalid syntax in npc_parsesrcfile * Removed the attempts to recover from invalid syntax in npc_parsesrcfile
since they can produce incorrect results (spaces in sscanf can match since they can produce incorrect results (spaces in sscanf can match

View File

@ -351,43 +351,13 @@ int settick_timer(int tid, unsigned int tick)
return tick; return tick;
} }
//Correcting the heap when the tick overflows is an idea taken from jA to
//prevent timer problems. Thanks to [End of Exam] for providing the required data. [Skotlex]
//This funtion will rearrange the heap and assign new tick values.
static void fix_timer_heap(unsigned int tick)
{
if (timer_heap_num >= 0 && tick < 0x00010000 && timer_data[timer_heap[0]].tick > 0xf0000000)
{ //The last timer is way too far into the future, and the current tick is too close to 0, overflow was very likely
//(not perfect, but will work as long as the timer is not expected to happen 50 or so days into the future)
int i;
int *tmp_heap;
for (i=0; i < timer_heap_num && timer_data[timer_heap[i]].tick > 0xf0000000; i++)
{ //All functions with high tick value should had been executed already...
timer_data[timer_heap[i]].tick = 0;
}
//Move elements to readjust the heap.
tmp_heap = aCalloc(sizeof(int), i);
memcpy(tmp_heap, timer_heap, i*sizeof(int));
memmove(timer_heap, &timer_heap[i], (timer_heap_num-i)*sizeof(int));
memmove(&timer_heap[timer_heap_num-i], tmp_heap, i*sizeof(int));
aFree(tmp_heap);
}
}
/// Executes all expired timers. /// Executes all expired timers.
/// Returns the value of the smallest non-expired timer (or 1 second if there aren't any). /// Returns the value of the smallest non-expired timer (or 1 second if there aren't any).
int do_timer(unsigned int tick) int do_timer(unsigned int tick)
{ {
int nextmin = 1000; // return value int nextmin = 1000; // return value
static int fix_heap_flag = 0; //Flag for fixing the stack only once per tick loop. May not be the best way, but it's all I can think of currently :X [Skotlex]
int i; int i;
if( tick < 0x010000 && fix_heap_flag )
{
fix_timer_heap(tick);
fix_heap_flag = 0;
}
// process all timers one by one // process all timers one by one
while( timer_heap_num ) while( timer_heap_num )
{ {
@ -444,9 +414,6 @@ int do_timer(unsigned int tick)
if( nextmin < TIMER_MIN_INTERVAL ) if( nextmin < TIMER_MIN_INTERVAL )
nextmin = TIMER_MIN_INTERVAL; nextmin = TIMER_MIN_INTERVAL;
if( UINT_MAX - nextmin < tick ) //Tick will loop, rearrange the heap on the next iteration.
fix_heap_flag = 1;
return nextmin; return nextmin;
} }

View File

@ -6712,7 +6712,7 @@ int atcommand_uptime(const int fd, struct map_session_data* sd, const char* comm
int atcommand_changesex(const int fd, struct map_session_data* sd, const char* command, const char* message) int atcommand_changesex(const int fd, struct map_session_data* sd, const char* command, const char* message)
{ {
nullpo_retr(-1, sd); nullpo_retr(-1, sd);
chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0); chrif_changesex(sd);
return 0; return 0;
} }

View File

@ -1411,6 +1411,7 @@ int charcommand_stpoint(const int fd, struct map_session_data* sd, const char* c
*------------------------------------------*/ *------------------------------------------*/
int charcommand_changesex(const int fd, struct map_session_data* sd, const char* command, const char* message) int charcommand_changesex(const int fd, struct map_session_data* sd, const char* command, const char* message)
{ {
struct map_session_data *pl_sd;
char player[NAME_LENGTH]; char player[NAME_LENGTH];
nullpo_retr(-1, sd); nullpo_retr(-1, sd);
@ -1419,18 +1420,17 @@ int charcommand_changesex(const int fd, struct map_session_data* sd, const char*
return -1; return -1;
} }
// check player name if ((pl_sd = map_nick2sd(player)) == NULL)
if (strlen(player) < 4) { {
clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters. clif_displaymessage(fd, msg_txt(3)); // Character not found.
return -1; return -1;
} else if (strlen(player) > 23) {
clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
return -1;
} else {
chrif_char_ask_name(sd->status.account_id, player, 5, 0, 0, 0, 0, 0, 0); // type: 5 - changesex
clif_displaymessage(fd, msg_table[88]); // Character name sent to char-server to ask it.
} }
if (pc_isGM(sd) < pc_isGM(pl_sd)) {
clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
return -1;
}
clif_displaymessage(fd, msg_table[88]); // Character name sent to char-server to ask it.
chrif_changesex(pl_sd);
return 0; return 0;
} }

View File

@ -62,7 +62,7 @@ static const int packet_len_table[0x3d] = { // U - used, F - free
//2b0e: Outgoing, chrif_char_ask_name -> 'Do some operations (change sex, ban / unban etc)' //2b0e: Outgoing, chrif_char_ask_name -> 'Do some operations (change sex, ban / unban etc)'
//2b0f: Incoming, chrif_char_ask_name_answer -> 'answer of the 2b0e' //2b0f: Incoming, chrif_char_ask_name_answer -> 'answer of the 2b0e'
//2b10: Outgoing, chrif_updatefamelist -> 'Update the fame ranking lists and send them' //2b10: Outgoing, chrif_updatefamelist -> 'Update the fame ranking lists and send them'
//2b11: Outgoing, chrif_changesex -> 'change sex of acc X' //2b11: FREE
//2b12: Incoming, chrif_divorce -> 'divorce a wedding of charid X and partner id X' //2b12: Incoming, chrif_divorce -> 'divorce a wedding of charid X and partner id X'
//2b13: Incoming, chrif_accountdeletion -> 'Delete acc XX, if the player is on, kick ....' //2b13: Incoming, chrif_accountdeletion -> 'Delete acc XX, if the player is on, kick ....'
//2b14: Incoming, chrif_accountban -> 'not sure: kick the player with message XY' //2b14: Incoming, chrif_accountban -> 'not sure: kick the player with message XY'
@ -593,7 +593,7 @@ int chrif_changeemail(int id, const char *actual_email, const char *new_email)
* S 2b0e <accid>.l <name>.24B <type>.w { <year>.w <month>.w <day>.w <hour>.w <minute>.w <second>.w } * S 2b0e <accid>.l <name>.24B <type>.w { <year>.w <month>.w <day>.w <hour>.w <minute>.w <second>.w }
* Send an account modification request to the login server (via char server). * Send an account modification request to the login server (via char server).
* type of operation: * type of operation:
* 1: block, 2: ban, 3: unblock, 4: unban, 5: changesex * 1: block, 2: ban, 3: unblock, 4: unban, 5: changesex (use next function for 5)
*------------------------------------------*/ *------------------------------------------*/
int chrif_char_ask_name(int acc, const char* character_name, unsigned short operation_type, int year, int month, int day, int hour, int minute, int second) int chrif_char_ask_name(int acc, const char* character_name, unsigned short operation_type, int year, int month, int day, int hour, int minute, int second)
{ {
@ -613,23 +613,21 @@ int chrif_char_ask_name(int acc, const char* character_name, unsigned short oper
WFIFOW(char_fd,42) = second; WFIFOW(char_fd,42) = second;
} }
WFIFOSET(char_fd,44); WFIFOSET(char_fd,44);
return 0; return 0;
} }
/*========================================== int chrif_changesex(struct map_session_data *sd)
* <EFBFBD>«ÊÏ»v<EFBFBD>
*------------------------------------------*/
int chrif_changesex(int id, int sex)
{ {
chrif_check(-1); chrif_check(-1);
WFIFOHEAD(char_fd,44);
WFIFOW(char_fd,0) = 0x2b0e;
WFIFOL(char_fd,2) = sd->status.account_id;
safestrncpy((char*)WFIFOP(char_fd,6), sd->status.name, NAME_LENGTH);
WFIFOW(char_fd,30) = 5;
WFIFOSET(char_fd,44);
WFIFOHEAD(char_fd,9); clif_displaymessage(sd->fd, "Need disconnection to perform change-sex request...");
WFIFOW(char_fd,0) = 0x2b11; map_quit(sd);
WFIFOW(char_fd,2) = 9;
WFIFOL(char_fd,4) = id;
WFIFOB(char_fd,8) = sex;
WFIFOSET(char_fd,9);
return 0; return 0;
} }
@ -714,60 +712,49 @@ int chrif_changedsex(int fd)
if (battle_config.etc_log) if (battle_config.etc_log)
ShowNotice("chrif_changedsex %d.\n", acc); ShowNotice("chrif_changedsex %d.\n", acc);
sd = map_id2sd(acc); sd = map_id2sd(acc);
if (acc > 0) { if (sd) { //Normally there should not be a char logged on right now!
if (sd != NULL && sd->status.sex != sex) { if (sd->status.sex == sex)
sd->status.sex = !sd->status.sex; return 0; //Do nothing? Likely safe.
sd->status.sex = !sd->status.sex;
// to avoid any problem with equipment and invalid sex, equipment is unequiped. // reset skill of some job
for (i = 0; i < EQI_MAX; i++) { if ((sd->class_&MAPID_UPPERMASK) == MAPID_BARDDANCER) {
if (sd->equip_index[i] >= 0) // remove specifical skills of Bard classes
pc_unequipitem((struct map_session_data*)sd, sd->equip_index[i], 2); for(i = 315; i <= 322; i++) {
} if (sd->status.skill[i].id > 0 && !sd->status.skill[i].flag) {
// reset skill of some job if (sd->status.skill_point > USHRT_MAX - sd->status.skill[i].lv)
if ((sd->class_&MAPID_UPPERMASK) == MAPID_BARDDANCER) { sd->status.skill_point = USHRT_MAX;
// remove specifical skills of Bard classes else
for(i = 315; i <= 322; i++) { sd->status.skill_point += sd->status.skill[i].lv;
if (sd->status.skill[i].id > 0 && !sd->status.skill[i].flag) { sd->status.skill[i].id = 0;
if (sd->status.skill_point > USHRT_MAX - sd->status.skill[i].lv) sd->status.skill[i].lv = 0;
sd->status.skill_point = USHRT_MAX;
else
sd->status.skill_point += sd->status.skill[i].lv;
sd->status.skill[i].id = 0;
sd->status.skill[i].lv = 0;
}
} }
// remove specifical skills of Dancer classes
for(i = 323; i <= 330; i++) {
if (sd->status.skill[i].id > 0 && !sd->status.skill[i].flag) {
if (sd->status.skill_point > USHRT_MAX - sd->status.skill[i].lv)
sd->status.skill_point = USHRT_MAX;
else
sd->status.skill_point += sd->status.skill[i].lv;
sd->status.skill[i].id = 0;
sd->status.skill[i].lv = 0;
}
}
clif_updatestatus(sd, SP_SKILLPOINT);
// change job if necessary
if (sd->status.sex) //Changed from Dancer
sd->status.class_ -= 1;
else //Changed from Bard
sd->status.class_ += 1;
//sd->class_ needs not be updated as both Dancer/Bard are the same.
} }
// save character // remove specifical skills of Dancer classes
//chrif_save(sd,1); Character will be saved on session closed -> map_quit for(i = 323; i <= 330; i++) {
sd->login_id1++; // change identify, because if player come back in char within the 5 seconds, he can change its characters if (sd->status.skill[i].id > 0 && !sd->status.skill[i].flag) {
// do same modify in login-server for the account, but no in char-server (it ask again login_id1 to login, and don't remember it) if (sd->status.skill_point > USHRT_MAX - sd->status.skill[i].lv)
clif_displaymessage(sd->fd, "Your sex has been changed (need disconnection by the server)..."); sd->status.skill_point = USHRT_MAX;
clif_setwaitclose(sd->fd); // forced to disconnect for the change else
} sd->status.skill_point += sd->status.skill[i].lv;
} else { sd->status.skill[i].id = 0;
if (sd != NULL) { sd->status.skill[i].lv = 0;
ShowError("chrif_changedsex failed.\n"); }
}
clif_updatestatus(sd, SP_SKILLPOINT);
// change job if necessary
if (sd->status.sex) //Changed from Dancer
sd->status.class_ -= 1;
else //Changed from Bard
sd->status.class_ += 1;
//sd->class_ needs not be updated as both Dancer/Bard are the same.
} }
// save character
sd->login_id1++; // change identify, because if player come back in char within the 5 seconds, he can change its characters
// do same modify in login-server for the account, but no in char-server (it ask again login_id1 to login, and don't remember it)
clif_displaymessage(sd->fd, "Your sex has been changed (need disconnection by the server)...");
clif_setwaitclose(sd->fd); // forced to disconnect for the change
} }
return 0; return 0;
} }

View File

@ -46,7 +46,7 @@ int chrif_char_offline(struct map_session_data *sd);
int chrif_char_reset_offline(void); int chrif_char_reset_offline(void);
int send_users_tochar(void); int send_users_tochar(void);
int chrif_char_online(struct map_session_data *sd); int chrif_char_online(struct map_session_data *sd);
int chrif_changesex(int id, int sex); int chrif_changesex(struct map_session_data *sd);
int chrif_chardisconnect(struct map_session_data *sd); int chrif_chardisconnect(struct map_session_data *sd);
int check_connect_char_server(int tid, unsigned int tick, int id, int data); int check_connect_char_server(int tid, unsigned int tick, int id, int data);

View File

@ -233,7 +233,7 @@ int party_recv_info(struct party *sp)
sd = map_id2sd(p->party.member[i].account_id); sd = map_id2sd(p->party.member[i].account_id);
if (sd && sd->status.party_id==p->party.party_id if (sd && sd->status.party_id==p->party.party_id
&& sd->status.char_id == p->party.member[i].char_id && sd->status.char_id == p->party.member[i].char_id
&& !sd->state.waitingdisconnect) && sd->state.auth && !sd->state.waitingdisconnect)
p->data[i].sd = sd; p->data[i].sd = sd;
} }
party_check_state(p); party_check_state(p);

View File

@ -4778,7 +4778,6 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
break; break;
case SC_QUAGMIRE: case SC_QUAGMIRE:
case SC_DECREASEAGI: case SC_DECREASEAGI:
case SC_SIGNUMCRUCIS:
case SC_PROVOKE: case SC_PROVOKE:
case SC_ROKISWEIL: case SC_ROKISWEIL:
case SC_COMA: case SC_COMA: