Skip to content

Commit

Permalink
* This should fix bug #3470 (InvAdd failed - could not add 1 item...)
Browse files Browse the repository at this point in the history
* Introduces CL_InvDelTime to ensure the InvDel events are properly scheduled
  in relation with the corresponding InvAdd events.
  • Loading branch information
DarkRain committed Aug 7, 2013
1 parent 9305a39 commit 268e007
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/client/battlescape/events/e_main.cpp
Expand Up @@ -120,7 +120,7 @@ const eventRegister_t events[] = {
{E(EV_ACTOR_WOUND), "sbbb", CL_ActorWound, nullptr, nullptr},

{E(EV_INV_ADD), "s*", CL_InvAdd, CL_InvAddTime, CL_CheckDefault},
{E(EV_INV_DEL), "sbbb", CL_InvDel, nullptr, CL_CheckDefault},
{E(EV_INV_DEL), "sbbb", CL_InvDel, CL_InvDelTime, CL_CheckDefault},
{E(EV_INV_AMMO), "sbbbbb", CL_InvAmmo, nullptr, nullptr},
{E(EV_INV_RELOAD), "sbbbbb", CL_InvReload, CL_InvReloadTime, nullptr},
/** @sa G_ReadItem, G_WriteItem */
Expand Down
14 changes: 14 additions & 0 deletions src/client/battlescape/events/event/inventory/e_event_invdel.cpp
Expand Up @@ -27,6 +27,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../../cl_localentity.h"
#include "e_event_invdel.h"

/**
* @brief Decides if following events should be delayed.
*/
int CL_InvDelTime (const struct eventRegister_s *self, dbuffer *msg, eventTiming_t *eventTiming)
{
if (eventTiming->parsedDeath) { /* drop items after death (caused by impact) */
return eventTiming->impactTime + 400;
} else if (eventTiming->impactTime > cl.time) { /* item thrown on the ground */
return eventTiming->impactTime + 75;
}

return eventTiming->nextTime;
}

/**
* @sa CL_InvAdd
*/
Expand Down
Expand Up @@ -26,4 +26,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#include "../../e_main.h"

int CL_InvDelTime(const struct eventRegister_s *self, dbuffer *msg, eventTiming_t *eventTiming);
void CL_InvDel(const eventRegister_t *self, dbuffer *msg);

0 comments on commit 268e007

Please sign in to comment.