/* * ================= * PF_objerror * * Dumps out self, then an error message. The program is aborted and self is * removed, but the level can continue. * * objerror(value) * ================= */ static void PF_objerror() { string s = PF_VarString(0); Con.Print("======OBJECT ERROR in {0}:\n{1}\n", GetString(Progs.xFunction.s_name), s); edict_t ed = Server.ProgToEdict(Progs.GlobalStruct.self); Progs.Print(ed); Server.FreeEdict(ed); Host.Error("Program error"); }
static void PF_makestatic() { edict_t ent = GetEdict(OFS.OFS_PARM0); MessageWriter msg = Server.sv.signon; msg.WriteByte(Protocol.svc_spawnstatic); msg.WriteByte(Server.ModelIndex(Progs.GetString(ent.v.model))); msg.WriteByte((int)ent.v.frame); msg.WriteByte((int)ent.v.colormap); msg.WriteByte((int)ent.v.skin); for (int i = 0; i < 3; i++) { msg.WriteCoord(Mathlib.Comp(ref ent.v.origin, i)); msg.WriteAngle(Mathlib.Comp(ref ent.v.angles, i)); } // throw the entity away now Server.FreeEdict(ent); }
/// <summary> /// ED_LoadFromFile /// The entities are directly placed in the array, rather than allocated with /// ED_Alloc, because otherwise an error loading the map would have entity /// number references out of order. /// /// Creates a server's entity / program execution context by /// parsing textual entity definitions out of an ent file. /// /// Used for both fresh maps and savegame loads. A fresh map would also need /// to call ED_CallSpawnFunctions () to let the objects initialize themselves. /// </summary> public static void LoadFromFile(string data) { edict_t ent = null; int inhibit = 0; Progs.GlobalStruct.time = (float)Server.sv.time; // parse ents while (true) { // parse the opening brace data = Common.Parse(data); if (data == null) { break; } if (Common.Token != "{") { Sys.Error("ED_LoadFromFile: found {0} when expecting {", Common.Token); } if (ent == null) { ent = Server.EdictNum(0); } else { ent = Server.AllocEdict(); } data = ParseEdict(data, ent); // remove things from different skill levels or deathmatch if (Host.Deathmatch != 0) { if (((int)ent.v.spawnflags & SpawnFlags.SPAWNFLAG_NOT_DEATHMATCH) != 0) { Server.FreeEdict(ent); inhibit++; continue; } } else if ((Host.CurrentSkill == 0 && ((int)ent.v.spawnflags & SpawnFlags.SPAWNFLAG_NOT_EASY) != 0) || (Host.CurrentSkill == 1 && ((int)ent.v.spawnflags & SpawnFlags.SPAWNFLAG_NOT_MEDIUM) != 0) || (Host.CurrentSkill >= 2 && ((int)ent.v.spawnflags & SpawnFlags.SPAWNFLAG_NOT_HARD) != 0)) { Server.FreeEdict(ent); inhibit++; continue; } // // immediately call spawn function // if (ent.v.classname == 0) { Con.Print("No classname for:\n"); Print(ent); Server.FreeEdict(ent); continue; } // look for the spawn function int func = IndexOfFunction(GetString(ent.v.classname)); if (func == -1) { Con.Print("No spawn function for:\n"); Print(ent); Server.FreeEdict(ent); continue; } Progs.GlobalStruct.self = Server.EdictToProg(ent); Execute(func); } Con.DPrint("{0} entities inhibited\n", inhibit); }
static void PF_Remove() { edict_t ed = GetEdict(OFS.OFS_PARM0); Server.FreeEdict(ed); }