e_event_actormove.c

Go to the documentation of this file.
00001 
00005 /*
00006 Copyright (C) 2002-2010 UFO: Alien Invasion.
00007 
00008 This program is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU General Public License
00010 as published by the Free Software Foundation; either version 2
00011 of the License, or (at your option) any later version.
00012 
00013 This program is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016 
00017 See the GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00023 */
00024 
00025 #include "../../../../client.h"
00026 #include "../../../cl_localentity.h"
00027 #include "e_event_actormove.h"
00028 
00029 int CL_ActorDoMoveTime (const eventRegister_t *self, struct dbuffer *msg, const int dt)
00030 {
00031 #if 0
00032     le_t *le;
00033     int number, i;
00034     int time = cl.time;
00035 
00036     number = NET_ReadShort(msg);
00037     /* get le */
00038     le = LE_Get(number);
00039     if (!le)
00040         LE_NotFoundError(number);
00041 
00042     for (i = 0; i < le->pathLength; i++) {
00043         const byte fulldv = le->path[i];
00044         const byte dir = getDVdir(fulldv);
00045         time += LE_ActorGetStepTime(le, dir, le->pathPos);
00046     }
00047 
00048     return time;
00049 #else
00050     return cl.time;
00051 #endif
00052 }
00053 
00061 void CL_ActorDoMove (const eventRegister_t *self, struct dbuffer *msg)
00062 {
00063     le_t *le;
00064     int number, i, newPathLength;
00065 
00066     number = NET_ReadShort(msg);
00067     /* get le */
00068     le = LE_Get(number);
00069     if (!le)
00070         LE_NotFoundError(number);
00071 
00072     if (!LE_IsActor(le))
00073         Com_Error(ERR_DROP, "Can't move, LE doesn't exist or is not an actor (number: %i, type: %i)\n",
00074             number, le->type);
00075 
00076     if (LE_IsDead(le))
00077         Com_Error(ERR_DROP, "Can't move, actor on team %i dead", le->team);
00078 
00079     /* lock this le for other events, the corresponding unlock is in LE_DoEndPathMove() */
00080     LE_Lock(le);
00081     newPathLength = NET_ReadByte(msg);
00082     if (le->pathLength > 0) {
00083         if (le->pathLength == le->pathPos) {
00084             LE_DoEndPathMove(le);
00085             le->pathLength = le->pathPos = 0;
00086         } else {
00087             Com_Error(ERR_DROP, "Actor (entnum: %i) on team %i is still moving (%i steps left).  Times: %i, %i, %i",
00088                     le->entnum, le->team, le->pathLength - le->pathPos, le->startTime, le->endTime, cl.time);
00089         }
00090     }
00091 
00092     le->pathLength = newPathLength;
00093     if (le->pathLength >= MAX_LE_PATHLENGTH)
00094         Com_Error(ERR_DROP, "Overflow in pathLength");
00095 
00096     /* Also get the final position */
00097     le->newPos[0] = NET_ReadByte(msg);
00098     le->newPos[1] = NET_ReadByte(msg);
00099     le->newPos[2] = NET_ReadByte(msg);
00100 
00101     for (i = 0; i < le->pathLength; i++) {
00102         le->path[i] = NET_ReadByte(msg); 
00103         le->speed[i] = NET_ReadShort(msg);
00104         le->pathContents[i] = NET_ReadShort(msg);
00105     }
00106 
00107     /* activate PathMove function */
00108     FLOOR(le) = NULL;
00109     LE_SetThink(le, LET_StartPathMove);
00110     le->pathPos = 0;
00111     le->startTime = cl.time;
00112     le->endTime = cl.time;
00113 }

Generated by  doxygen 1.6.2