Skip to content

Commit

Permalink
Added support for server specified spell/buff durations.
Browse files Browse the repository at this point in the history
  • Loading branch information
pjbroad committed May 31, 2014
1 parent 294db3f commit c4edeaf
Show file tree
Hide file tree
Showing 10 changed files with 231 additions and 54 deletions.
5 changes: 5 additions & 0 deletions client_serv.h
Expand Up @@ -699,6 +699,9 @@ typedef enum

#define DO_EMOTE 70

/* send: 16 bit buff bit-mask (only one set bit), server responds with SEND_BUFF_DURATION */
#define GET_BUFF_DURATION 71

#define LOG_IN 140
#define CREATE_CHAR 141

Expand Down Expand Up @@ -810,6 +813,8 @@ typedef enum
#define QUEST_FINISHED 94
/* sent: 5 x 32 bit integers, each active bit is an achievement the last "You see: name" player has */
#define SEND_ACHIEVEMENTS 95
/* sent: 1 single byte duration, to get the time remaining multiply the by 10, the result is seconds */
#define SEND_BUFF_DURATION 96

#define SEND_WEATHER 100

Expand Down
3 changes: 3 additions & 0 deletions draw_scene.c
Expand Up @@ -22,6 +22,7 @@
#include "shadows.h"
#include "skeletons.h"
#include "sky.h"
#include "spells.h"
#include "sound.h"
#include "storage.h"
#include "text.h"
Expand Down Expand Up @@ -174,6 +175,8 @@ void draw_scene()
check_afk_state();
/* the timer in the hud */
update_hud_timer();
/* check if we need to do buff duration requests */
check_then_do_buff_duration_request();
/* until next time */
last_half_second_timer = current_time;
}
Expand Down
29 changes: 29 additions & 0 deletions multiplayer.c
Expand Up @@ -104,6 +104,26 @@ Uint32 next_second_time = 0;
short real_game_minute = 0;
short real_game_second = 0;

/* real_game_second_valid set when we know the server seconds */
static short real_game_second_valid = 0;
int is_real_game_second_valid(void) { return real_game_second_valid; }
void set_real_game_second_valid(void) { real_game_second_valid = 1; }

/* get the current game time in seconds */
Uint32 get_game_time_sec(void)
{
return real_game_minute * 60 + real_game_second;
}

/* get the difference between the supplied time and current game time, allowing for wrap round */
Uint32 diff_game_time_sec(Uint32 ref_time)
{
Uint32 curr_game_time = get_game_time_sec();
if (ref_time > curr_game_time)
curr_game_time += 6 * 60 * 60;
return curr_game_time - ref_time;
}


/*
* Date handling code:
Expand Down Expand Up @@ -758,6 +778,7 @@ void process_message_from_server (const Uint8 *in_data, int data_length)
real_game_minute= SDL_SwapLE16(*((short *)(in_data+3)));
real_game_minute %= 360;
real_game_second = 0;
set_real_game_second_valid();
next_second_time = cur_time+1000;
if (real_game_minute < last_real_game_minute)
invalidate_date();
Expand Down Expand Up @@ -2185,6 +2206,14 @@ void process_message_from_server (const Uint8 *in_data, int data_length)
free(achievement_data);
}
break;
case SEND_BUFF_DURATION:
{
if (data_length <= 3)
LOG_WARNING("CAUTION: Possibly forged/invalid SEND_BUFF_DURATION packet received.\n");
else
here_is_a_buff_duration((Uint8)in_data[3]);
break;
}
default:
{
// Unknown packet type??
Expand Down
28 changes: 28 additions & 0 deletions multiplayer.h
Expand Up @@ -36,6 +36,34 @@ extern Uint32 next_second_time; /*!< the time of the next second */
extern short real_game_minute; /*!< the real game minute */
extern short real_game_second; /*!< the real game second */

/*!
* \brief check validity of game seconds
*
* \retval true if we have set seconds.
*/
int is_real_game_second_valid(void);

/*!
* \brief Set game seconds as valid.
*
*/
void set_real_game_second_valid(void);

/*!
* \brief Get the current game time.
*
* \retval game time in seconds.
*/
Uint32 get_game_time_sec(void);

/*!
* \brief Get the time difference from current game time.
*
* \param the relative time to compare
*
* \retval the time difference in seconds, wrapped appropriately
*/
Uint32 diff_game_time_sec(Uint32 ref_time);

extern time_t last_heart_beat; /*!< a timestamp that inidicates when the last message was sent to the server */

Expand Down
1 change: 1 addition & 0 deletions named_colours.cpp
Expand Up @@ -182,6 +182,7 @@ namespace ELGL_Colour
add("minimap.otherplayer", Colour_Tuple(1.0f, 1.0f, 1.0f));
add("global.mousehighlight", Colour_Tuple(0.5f, 0.5f, 1.0f));
add("global.mouseselected", Colour_Tuple(0.4f, 0.8f, 1.0f));
add("buff.duration.background", Colour_Tuple(0.1f, 0.3f, 1.0f, 0.7f));
}

} // end namespace
Expand Down
1 change: 1 addition & 0 deletions named_colours.xml
Expand Up @@ -14,6 +14,7 @@
<colour name="minimap.otherplayer" r="1.0" g="1.0" b="1.0"/>
<colour name="global.mousehighlight" r="0.5" g="0.5" b="1.0"/>
<colour name="global.mouseselected" r="0.4" g="0.8" b="1.0"/>
<colour name="buff.duration.background" r="0.1" g="0.3" b="1.0" a="0.7"/>

<!-- Alpha can be specified too
<colour name="test" r="1.0" g="1.0" b="1.0" a="1.0"/>
Expand Down

21 comments on commit c4edeaf

@ht990332
Copy link

Choose a reason for hiding this comment

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

I updated and installed the new spells.xml
I don't see a spell timer anymore.

@pjbroad
Copy link
Collaborator Author

@pjbroad pjbroad commented on c4edeaf Jun 1, 2014

Choose a reason for hiding this comment

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

Radu is still working on the server code. It works on the test server (though still some fixes for Radu to apply). I do not know when he will do that or update the main server. I was doing to wait for him to do that before committing but he told me not to.

@ht990332
Copy link

Choose a reason for hiding this comment

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

Ah ok, thank you.

@ht990332
Copy link

Choose a reason for hiding this comment

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

It works now after server restart.

@feeltheburn
Copy link
Contributor

Choose a reason for hiding this comment

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

How's it handling the "permanent" spells for Phoenix?
Need that to be tested? I've been real-life busy of late but I can try and squeeze in a test of it on test server as soon as I can.

@pjbroad
Copy link
Collaborator Author

@pjbroad pjbroad commented on c4edeaf Jun 8, 2014

Choose a reason for hiding this comment

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

There is nothing coded in for Phoenix, its not one of the Buffs in the protocol list. I suggest you ask Radu about it.

@feeltheburn
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm, kk.
Should be able to tell if someone's shapeshifted into phoenix though, right? Then for those two spells, if they're active when the person shifts (uses phoenix glyph, or logs in still as a phoenix), have it stay at "max" for the duration.

Only question is if the spells auto-disappear when you de-phoenix, or it then starts the countdown to end. That I can test at least.

@ht990332
Copy link

Choose a reason for hiding this comment

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

I guess you are talking about when you cast MI while shapeshifted into Phoenix.
The expected behavior is no countdown for MI spell while shapeshifted because MI stays as long as you are shapeshifted. Then the countdown should start when you deshapeshift? I have not tried Phoenix yet.
Perhaps you can try it and post if it works as expected?

@feeltheburn
Copy link
Contributor

Choose a reason for hiding this comment

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

True Sight doesn't show anything on time (not phoenix-related). That could be very useful if possible.

Phoenix: When you use MI (and TS after level 5 phoenix) and turn into phoenix before the spell dies off, the spells stay with you until you return to normal.

When it disappears after you return to normal is... I'm not sure. On one test both spells ended at the same time after 30 seconds, on another test 10 seconds. Doesn't seem to compute based on how long the spell normally lasts either, as MI should last longer than TS for me, but both disappear at the same time. (Will need to ask radu about that.)

-MY TESTS-

On test server with current code: On turning to Phoenix, the timer on MI is decreasing as normal and disappears, though MI is kept throughout time in phoenix form. As mentioned, TS doesn't have a timer. The timing doesn't reappear on turning to normal to count off before the spell ends either.

Not sure what can be done about this, mainly because the time after de-phoenixing before the spells disappear seems to fluctuate and I can't see the reason for it.

@feeltheburn
Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, radu says Phoenix will have to be coded on client end separately. (Also mentioned he's not finished with server end, so hoping that means TS will get a timer)

1- On phoenix glyph use (and on log in and still in phoenix shape), check for TS* and MI in use. If they are, set the timer at maximum and leave it there.

*Only on phoenix level 5 or higher for TS. I don't know if you have that info to work with without server contact.

2- On de-phoenix ("use" click to manually stop, or on running out of creature food), get a new timer from the server (radu sez).

@pjbroad
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The True Sight timer work OK for me, both the spell and the potion (the latter was a surprise). Both time a little short but that is one thing I know Radu was working on. I have never transformed to a Phoenix so its going to be hard to test. I hope the player actor structure shows the state change (will investigate), how do you know the Phoenix level?

@ht990332
Copy link

Choose a reason for hiding this comment

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

If it works like mule, click 'eye' (not 'use') on yourself while shapeshifted.

@feeltheburn
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Yes, you "eye" yourself, and it shows text as seen in this screenshot
    http://i95.photobucket.com/albums/l125/FlamesterBurn/EL-Blog/PhoenixLvl9_zps8b34b501.jpg

  2. FTR (non-phoenix related), tested all spells this should work with, every shield, TS, and Invisibility.

Shield times are perfect! But I'm still not seeing timers on TS or Invisibility. Tested both with spells and potions on main.
As can be seen here (pic from main server, test shows same):
http://i.imgur.com/llCrDQs.png

  1. Timers need to be checked on login if possible. If you're spelled up on logout and log back in with the spells intact, there's no timer.

@pjbroad
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note seeing TS/Invisibility: I see the duration backgrounds are green in your picture, but they are blue by default. Did you change that or are you not using the latest code? The latest code changes, this commit, also work for spells that are active at login.

@feeltheburn
Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, yeah seems I had a previous git download. :-/ Coulda swore I'd downloaded the zip fresh here.

I'm seeing them now, and yes they're blue. DOH! (No clue why the old build made them green, they'd been green since you did the first code attempt for them.)

Confirmed both seeing TS/Invis, and spells active at login. Looking good! Gonna have to finally update my SUSE builds, heh.

Okay, so just the phoenix mode left. And since it's rarely used by anyone, mostly just for accuracy sake.

@pjbroad
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good news, I'll see what I can do for the phoenix mode. I changed the colour to blue to match other time out indicators such as for food and potions. However, I'm not sure it stands out enough. Perhaps the blue block could be made a bit larger or perhaps changed back to green or another colour. Suggestions welcome.

@feeltheburn
Copy link
Contributor

Choose a reason for hiding this comment

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

Color seems okay to me. Tested it over water, ice/snow maps, secret blue room in Irsis, C2 portal room, ran around Dra Syn... it showed well enough on all.

The green seemed fine, though I didn't background-check it like this. I wouldn't complain about either.

I'd say keep it blue for now, people keeping up with GIT can be considered testers. If there's an issue it'll come up.

Radu can do more invisi rat hunts, that'll really put it to the test. ;-) hehe

FTR: I also tested the other potions besides TS... Invisi, and the cold/heat/radiation protection pots. All work fine.

@feeltheburn
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug Report! ;-)

DerSachse and I both had this happen: If a spell is already in use, and you use the same spell again, the timer doesn't (always) restart.

In my case, yesterday I had Invisibility in use. Just as there was only a couple seconds to go, I used the spell again to remain invisi. I did, but the timer continued to count only on the first spell.

DerSachse had the same happen with the shield spell.

I can't see the circumstances that cause this, as most times this doesn't happen. But it is slipping by on rare occasion.

@pjbroad
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I spoke to DerSachse in game. It turned out that he/she had an old version of the spells.xml file where the shield buff was incorrect. Updating the file fixed the issue. Your issue, close to the time out, sounds different. I'll look into it.

@feeltheburn
Copy link
Contributor

Choose a reason for hiding this comment

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

More testing is showing more specific results.

All shields are fine. Regardless of when restarted, their timer restarts as well.

However, True Sight, Invisibility, and the pot-only Accuracy and Evasion are all not restarting timers, regardless of when you do the spell again if it's already active.

In all 4 of those, the timer tracks the first use of the spell only. Any re-use of the spell before that first timer expires does nothing, timer will stay at 0 once it runs out.

(This additional testing done on test server. The initial Invisi bug report was on main. Lemme know if you need testing on a specific server due to radu's changes.)

@pjbroad
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Briefly checked evasion potions. In this case, it looks like the server does not send a new SPELL_CAST message if its already active, it just extends the timer. Therefore the client does not know that it needs to ask for an updated duration. Shield and other spells get a new SPELL_CAST cast message.
Edit: Oops, the was a bug, fixed now.

Please sign in to comment.