From abd0c3a98bbbe6bcd0425351207120a00babe329 Mon Sep 17 00:00:00 2001 From: skotlex Date: Fri, 7 Dec 2007 08:44:52 +0000 Subject: - 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://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11867 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 7 ++++ src/common/timer.c | 33 --------------- src/map/atcommand.c | 2 +- src/map/charcommand.c | 18 ++++---- src/map/chrif.c | 111 ++++++++++++++++++++++---------------------------- src/map/chrif.h | 2 +- src/map/party.c | 2 +- src/map/status.c | 1 - 8 files changed, 68 insertions(+), 108 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 532d7c1dd..12fbf7100 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,13 @@ Date Added 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. +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 * Removed the attempts to recover from invalid syntax in npc_parsesrcfile since they can produce incorrect results (spaces in sscanf can match diff --git a/src/common/timer.c b/src/common/timer.c index a2be88876..5f1f17e2f 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -351,43 +351,13 @@ int settick_timer(int tid, unsigned int 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. /// Returns the value of the smallest non-expired timer (or 1 second if there aren't any). int do_timer(unsigned int tick) { 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; - if( tick < 0x010000 && fix_heap_flag ) - { - fix_timer_heap(tick); - fix_heap_flag = 0; - } - // process all timers one by one while( timer_heap_num ) { @@ -444,9 +414,6 @@ int do_timer(unsigned int tick) if( 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; } diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 81761a453..1a6e9509b 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -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) { 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; } diff --git a/src/map/charcommand.c b/src/map/charcommand.c index e44954a4c..5f6fb839e 100644 --- a/src/map/charcommand.c +++ b/src/map/charcommand.c @@ -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) { + struct map_session_data *pl_sd; char player[NAME_LENGTH]; nullpo_retr(-1, sd); @@ -1419,18 +1420,17 @@ int charcommand_changesex(const int fd, struct map_session_data* sd, const char* return -1; } - // check player name - if (strlen(player) < 4) { - clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters. + if ((pl_sd = map_nick2sd(player)) == NULL) + { + clif_displaymessage(fd, msg_txt(3)); // Character not found. return -1; - } else if (strlen(player) > 23) { - clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum. + } + 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; - } 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. } - + clif_displaymessage(fd, msg_table[88]); // Character name sent to char-server to ask it. + chrif_changesex(pl_sd); return 0; } diff --git a/src/map/chrif.c b/src/map/chrif.c index 03bed41b1..b2a3af4bf 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -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)' //2b0f: Incoming, chrif_char_ask_name_answer -> 'answer of the 2b0e' //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' //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' @@ -593,7 +593,7 @@ int chrif_changeemail(int id, const char *actual_email, const char *new_email) * S 2b0e .l .24B .w { .w .w .w .w .w .w } * Send an account modification request to the login server (via char server). * 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) { @@ -613,23 +613,21 @@ int chrif_char_ask_name(int acc, const char* character_name, unsigned short oper WFIFOW(char_fd,42) = second; } WFIFOSET(char_fd,44); - return 0; } -/*========================================== - * 性別変化要求 - *------------------------------------------*/ -int chrif_changesex(int id, int sex) +int chrif_changesex(struct map_session_data *sd) { 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); - WFIFOW(char_fd,0) = 0x2b11; - WFIFOW(char_fd,2) = 9; - WFIFOL(char_fd,4) = id; - WFIFOB(char_fd,8) = sex; - WFIFOSET(char_fd,9); + clif_displaymessage(sd->fd, "Need disconnection to perform change-sex request..."); + map_quit(sd); return 0; } @@ -714,60 +712,49 @@ int chrif_changedsex(int fd) if (battle_config.etc_log) ShowNotice("chrif_changedsex %d.\n", acc); sd = map_id2sd(acc); - if (acc > 0) { - if (sd != NULL && sd->status.sex != sex) { - sd->status.sex = !sd->status.sex; - - // to avoid any problem with equipment and invalid sex, equipment is unequiped. - for (i = 0; i < EQI_MAX; i++) { - if (sd->equip_index[i] >= 0) - pc_unequipitem((struct map_session_data*)sd, sd->equip_index[i], 2); - } - // reset skill of some job - if ((sd->class_&MAPID_UPPERMASK) == MAPID_BARDDANCER) { - // remove specifical skills of Bard classes - for(i = 315; i <= 322; 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; - } + if (sd) { //Normally there should not be a char logged on right now! + if (sd->status.sex == sex) + return 0; //Do nothing? Likely safe. + sd->status.sex = !sd->status.sex; + + // reset skill of some job + if ((sd->class_&MAPID_UPPERMASK) == MAPID_BARDDANCER) { + // remove specifical skills of Bard classes + for(i = 315; i <= 322; 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; } - // 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; - } + } + // 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 - //chrif_save(sd,1); Character will be saved on session closed -> map_quit - 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 - } - } else { - if (sd != NULL) { - 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; } diff --git a/src/map/chrif.h b/src/map/chrif.h index 1ae274f57..b440fcac6 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -46,7 +46,7 @@ int chrif_char_offline(struct map_session_data *sd); int chrif_char_reset_offline(void); int send_users_tochar(void); 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 check_connect_char_server(int tid, unsigned int tick, int id, int data); diff --git a/src/map/party.c b/src/map/party.c index 772fd9ab6..bfaf21b8a 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -233,7 +233,7 @@ int party_recv_info(struct party *sp) sd = map_id2sd(p->party.member[i].account_id); if (sd && sd->status.party_id==p->party.party_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; } party_check_state(p); diff --git a/src/map/status.c b/src/map/status.c index 204187402..2d6b3301e 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -4778,7 +4778,6 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val break; case SC_QUAGMIRE: case SC_DECREASEAGI: - case SC_SIGNUMCRUCIS: case SC_PROVOKE: case SC_ROKISWEIL: case SC_COMA: -- cgit v1.2.3-70-g09d2