예제 #1
0
/**
 * @brief Moves actor.
 * @param[in] self Pointer to the event structure that is currently executed
 * @param[in] msg The netchannel message
 * @sa LET_PathMove
 * @note EV_ACTOR_MOVE
 */
void CL_ActorDoMove (const eventRegister_t* self, dbuffer* msg)
{
	const int number = NET_ReadShort(msg);

	/* get le */
	le_t* le = LE_Get(number);
	if (!le)
		LE_NotFoundError(number);

	if (!LE_IsActor(le))
		Com_Error(ERR_DROP, "Can't move, LE doesn't exist or is not an actor (entnum: %i, type: %i)\n",
			number, le->type);

	if (LE_IsDead(le))
		Com_Error(ERR_DROP, "Can't move, actor on team %i dead (entnum: %i)", le->team, number);

	/* lock this le for other events, the corresponding unlock is in LE_DoEndPathMove() */
	LE_Lock(le);
	if (le->isMoving()) {
		if (le->pathLength == le->pathPos) {
			LE_DoEndPathMove(le);
		} else {
			Com_Error(ERR_DROP, "Actor (entnum: %i) on team %i is still moving (%i steps left).  Times: %i, %i, %i",
					le->entnum, le->team, le->pathLength - le->pathPos, le->startTime, le->endTime, cl.time);
		}
	}

	int i = 0;
	/* the end of this event is marked with a 0 */
	while (NET_PeekLong(msg) != 0) {
		NET_ReadByte(msg);
		le->dvtab[i] = NET_ReadShort(msg); /** Don't adjust dv values here- the whole thing is needed to move the actor! */
		le->speed[i] = NET_ReadShort(msg);
		le->pathContents[i] = NET_ReadShort(msg);
		i++;
	}
	le->pathLength = i;

	if (le->pathLength > MAX_ROUTE)
		Com_Error(ERR_DROP, "Overflow in pathLength (entnum: %i)", number);

	/* skip the end of move marker */
	NET_ReadLong(msg);
	/* Also get the final position */
	NET_ReadGPos(msg, le->newPos);

	if (VectorCompare(le->newPos, le->pos))
		Com_Error(ERR_DROP, "start and end pos are the same (entnum: %i)", number);

	/* activate PathMove function */
	le->resetFloor();
	if (LE_IsInvisible(le))
		/* Hack: this relies on the visibility events interrupting the EV_ACTOR_MOVE event */
		LE_SetThink(le, LET_HiddenMove);
	else
		LE_SetThink(le, LET_StartPathMove);
	le->pathPos = 0;
	le->startTime = cl.time;
	le->endTime = cl.time;
}
예제 #2
0
파일: netpack.cpp 프로젝트: AresAndy/ufoai
void NET_SkipFormat (dbuffer* buf, const char* format)
{
    while (*format) {
        const char typeID = *format++;

        switch (typeID) {
        case 'c':
            NET_ReadChar(buf);
            break;
        case 'b':
            NET_ReadByte(buf);
            break;
        case 's':
            NET_ReadShort(buf);
            break;
        case 'l':
            NET_ReadLong(buf);
            break;
        case 'p': {
            vec3_t v;
            NET_ReadPos(buf, v);
            break;
        }
        case 'g': {
            pos3_t p;
            NET_ReadGPos(buf, p);
            break;
        }
        case 'd': {
            vec3_t v;
            NET_ReadDir(buf, v);
            break;
        }
        case 'a':
            NET_ReadAngle(buf);
            break;
        case '!':
            format++;
            break;
        case '&':
            NET_ReadString(buf, nullptr, 0);
            break;
        case '*': {
            const int n = NET_ReadShort(buf);
            for (int i = 0; i < n; i++)
                NET_ReadByte(buf);
            break;
        }
        default:
            Com_Error(ERR_DROP, "ReadFormat: Unknown type!");
        }
    }
}
예제 #3
0
파일: sv_game.c 프로젝트: chrisglass/ufoai
static void SV_ReadGPos (pos3_t pos)
{
	NET_ReadGPos(sv->messageBuffer, pos);
}