e_event_addbrushmodel.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_addbrushmodel.h"
00028
00036 void CL_AddBrushModel (const eventRegister_t *self, struct dbuffer *msg)
00037 {
00038 le_t *le;
00039 int entnum, modelnum1, levelflags, speed;
00040 entity_type_t type;
00041 const cBspModel_t *model;
00042 int angle;
00043 vec3_t origin, angles;
00044
00045 NET_ReadFormat(msg, self->formatString, &type, &entnum, &modelnum1, &levelflags, &origin, &angles, &speed, &angle);
00046
00047 if (type != ET_BREAKABLE && type != ET_DOOR && type != ET_ROTATING)
00048 Com_Error(ERR_DROP, "Invalid le announced via EV_ADD_BRUSH_MODEL type: %i\n", type);
00049 else if (modelnum1 > MAX_MODELS || modelnum1 < 1)
00050 Com_Error(ERR_DROP, "Invalid le modelnum1 announced via EV_ADD_BRUSH_MODEL\n");
00051
00052
00053 le = LE_Get(entnum);
00054 if (le)
00055 Com_Error(ERR_DROP, "le announced a second time - le for entnum %i (type: %i) already exists (via EV_ADD_BRUSH_MODEL)\n", entnum, type);
00056
00057 le = LE_Add(entnum);
00058 assert(le);
00059
00060 le->rotationSpeed = speed / 100.0f;
00061 le->dir = angle;
00062 le->type = type;
00063 le->modelnum1 = modelnum1;
00064 le->levelflags = levelflags;
00065 le->addFunc = LE_BrushModelAction;
00066 LE_SetThink(le, LET_BrushModel);
00067
00068 VectorCopy(origin, le->origin);
00069 VectorCopy(angles, le->angles);
00070
00071 Com_sprintf(le->inlineModelName, sizeof(le->inlineModelName), "*%i", le->modelnum1);
00072 model = cl.model_clip[le->modelnum1];
00073 if (!model)
00074 Com_Error(ERR_DROP, "CL_AddBrushModel: Could not find inline model %i", le->modelnum1);
00075 le->model1 = R_RegisterModelShort(le->inlineModelName);
00076 if (!le->model1)
00077 Com_Error(ERR_DROP, "CL_AddBrushModel: Could not register inline model %i", le->modelnum1);
00078
00079
00080 VectorCopy(model->mins, le->mins);
00081 VectorCopy(model->maxs, le->maxs);
00082
00083
00084 CM_SetInlineModelOrientation(cl.mapTiles, le->inlineModelName, le->origin, le->angles);
00085
00086
00087 le->contents = CONTENTS_SOLID;
00088
00089 CL_RecalcRouting(le);
00090 }