From 9bf7c02194a042c3f9c96a8759ed21fc27104cab Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 1 Jul 2009 01:10:29 +0000 Subject: [PATCH] - The FlagLists structure cannot be anonymous if I want to use countof with it with GCC. - Added a stopping check to A_ChangeVelocity. SVN r1699 (trunk) --- src/thingdef/thingdef_codeptr.cpp | 28 +++++++++++++++++++++------- src/thingdef/thingdef_data.cpp | 6 +++--- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 1f09dc94f..bca0a7052 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -2040,6 +2040,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_Stop) } } +static void CheckStopped(AActor *self) +{ + if (self->player != NULL && + self->player->mo == self && + !(self->player->cheats & CF_PREDICTING) && + !(self->velx | self->vely | self->velz)) + { + self->player->mo->PlayIdle(); + self->player->velx = self->player->vely = 0; + } +} + //=========================================================================== // // A_Respawn @@ -2610,14 +2622,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ScaleVelocity) // If the actor was previously moving but now is not, and is a player, // update its player variables. (See A_Stop.) - if (was_moving && - self->player != NULL && - self->player->mo == self && - !(self->player->cheats & CF_PREDICTING) && - !(self->velx | self->vely | self->velz)) + if (was_moving) { - self->player->mo->PlayIdle(); - self->player->velx = self->player->vely = 0; + CheckStopped(self); } } @@ -2635,6 +2642,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeVelocity) ACTION_PARAM_FIXED(z, 2); ACTION_PARAM_INT(flags, 3); + INTBOOL was_moving = self->velx | self->vely | self->velz; + fixed_t vx = x, vy = y, vz = z; fixed_t sina = finesine[self->angle >> ANGLETOFINESHIFT]; fixed_t cosa = finecosine[self->angle >> ANGLETOFINESHIFT]; @@ -2656,4 +2665,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeVelocity) self->vely += vy; self->velz += vz; } + + if (was_moving) + { + CheckStopped(self); + } } diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index 76fc4d78c..18231e5cb 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -297,7 +297,7 @@ static FFlagDef PlayerPawnFlags[] = DEFINE_FLAG(PPF, NOTHRUSTWHENINVUL, APlayerPawn, PlayerFlags), }; -static const struct { const PClass *Type; FFlagDef *Defs; int NumDefs; } FlagLists[] = +static const struct FFlagList { const PClass *Type; FFlagDef *Defs; int NumDefs; } FlagLists[] = { { RUNTIME_CLASS(AActor), ActorFlags, countof(ActorFlags) }, { RUNTIME_CLASS(AInventory), InventoryFlags, countof(InventoryFlags) }, @@ -344,7 +344,7 @@ static FFlagDef *FindFlag (FFlagDef *flags, int numflags, const char *flag) FFlagDef *FindFlag (const PClass *type, const char *part1, const char *part2) { FFlagDef *def; - int i; + size_t i; if (part2 == NULL) { // Search all lists @@ -534,7 +534,7 @@ static int STACK_ARGS varcmp(const void * a, const void * b) void InitThingdef() { // Sort the flag lists - for (int i = 0; i < NUM_FLAG_LISTS; ++i) + for (size_t i = 0; i < NUM_FLAG_LISTS; ++i) { qsort (FlagLists[i].Defs, FlagLists[i].NumDefs, sizeof(FFlagDef), flagcmp); }