e_event_actormove.c
Go to the documentation of this file.00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
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
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
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
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
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 }