It is currently Thu, 09 September 2010 5:56 am




Post new topic Reply to topic  [ 29 posts ]  Go to page Previous  1, 2
Entity file entries for off-world transporting 
Author Message
WDL
User avatar

Joined: Tue, 24 September 2002 4:02 pm
Posts: 3420
Location: So. California
Post 
Well, LOX and Q2 are pretty much NOT C++. They are written in ordinary ANSI C with some Microsoft extensions thrown in and work-arounds for them tossed in for Linux/Unix portability. None of the files use any of the C++ keywords, classes, constructs or access modifiers. Q2/LOX is C, written in OOP style but not enforced by the compiler.

The whole project is a daunting mess when you try to comprehend it as a system. :) It's definitely not for beginners but I have seen some sharp young programmers tackle q2 game mods with success. There are plenty of strange style decisions and goofy errors in quake2 and all the mods, many of them inherited from the original design and handed down in tutorials and cross-pollenated mods. One group began an attempt to re-craft Quake2 to use the features of C++ but it didn't get very far. A complete, top-down redesign would be required IMHO, and it's way too late for anything like that except as an academic study. I would never recommend studying the Q2/LOX code for beginning programmers for fear it would create some bad habits.


Sat, 03 June 2006 5:13 pm
Profile YIM WWW
WOS Member
User avatar

Joined: Sat, 16 August 2003 4:41 pm
Posts: 1436
Location: New Jersey, USA
Post 
oh..... yea i can see how it wud take up ALL my time... ohwell... hehe.... i better stick to VB... at least i know that fairly well now :D

_________________
Image
Chris
http://skies.clanwos.org/index.html


Sat, 03 June 2006 5:16 pm
Profile ICQ YIM WWW
WDL
User avatar

Joined: Tue, 24 September 2002 4:02 pm
Posts: 3420
Location: So. California
Post 
I am happy to report that we now have offworld teleport entity functionality.

Some sample entities:
Code:
{
"message" "Offworld transport to\nLOXophilia\n(207.210.238.42:27910)"
"wait" "3"
"sounds" "2"
"target" "q2@207.210.238.42:27910"
"origin" "0 0 24"
"classname" "misc_offworld_teleporter"
}
{
"message" "Offworld Transport to\nLOX Unlimited(tm)\n(207.210.238.142:27912)"
"wait" "3"
"sounds" "2"
"target" "q2@207.210.238.142:27912"
"origin" "-384 -0 24"
"classname" "misc_offworld_teleporter"
}
{
"message" "Offworld Transport to\nMr. Bovine's Battlegound\n(mrbo.dyndns.org:27910)"
"wait" "3"
"sounds" "2"
"target" "q2@mrbo.dyndns.org:27910"
"origin" "0 -384 24"
"classname" "misc_offworld_teleporter"
}


These are all it takes to create teleporter pads in a game (provided you know the coordinates to place the origins) without modifying the maps.

These teleport pads spin, so you can see they are different from the usual telepads. They announce their targets with the centerprint that everyone liked in Phlem's original demo in the bitchweiser map.

You can test the offworld teleporter features on my Windows test server, dionysos.dnsalias.org:27912. If you have trouble seeing it in ASE, GS or XFire, force the connection. I will be making a Linux version for testing tomorrow or sometime this week. I have two maps configured, carena and bitchweiser, in it's original form with the special pads added under the new code.

Known bugs:

The entfile load method used for this forces the server admin to use entdump.exe on the target map creating a full ent file where he can add the offworld teleport objects. If you fail to do this the map won't have spawn pads and the server will crash when a player connects. The older custom ents load file doesn't behave this way. I still need to work out how best to fix this. One could also use R1ch's override files to create them.

The telepads don't have any special icons over them for recognition. I don't think this is an issue now that the centerprint problem is solved.

The text message needs to be prettier, maybe take "Offworld Transport to" out of the message field in the entity and put it into the code so all anyone has to do is provide "ServerName at IP" in the message text. Perhaps change the player say command to make it more visually appealing.

Thanks to Phlem for instigating this thread and giving me the inspiration and the kick in the butt I needed to get down with this feature.

QW


Sat, 03 June 2006 10:46 pm
Profile YIM WWW
WDL
User avatar

Joined: Sat, 20 July 2002 10:33 am
Posts: 3814
Location: Narnia
Post 
Nice work guys, this is a very awesome feature! I like how the teleport pad rotates, nice addition :!:

_________________
.-= Clan WOS - LOXophilia Server Status - LOX Downloads =-.


Sun, 04 June 2006 7:18 am
Profile WWW
Administrator
User avatar

Joined: Sat, 20 July 2002 4:14 am
Posts: 2695
Location: OR, USA
Post 
Wonderfulness!

I will have to hook up with you, QW, and get a code refresh so I can build a Linux flavor of this.

I am not adequately caffienated yet, so I do not quite understand the implications of the entity loading. Are you saying this code makes it mandatory to have an entity file for every map now?


Sun, 04 June 2006 8:16 am
Profile YIM
WDL
User avatar

Joined: Tue, 24 September 2002 4:02 pm
Posts: 3420
Location: So. California
Post 
No, only that you dump all the ents and include them with the new ones for every map you want to customize. Something about that g_ent.c module makes the server dump the internal map ents and overrides with the ent file. Not cool for our use but acceptable if you want to fully modify the ents in a map. Better than an add/drop list anyway.

The old entfile code in g_team.c works by adding the custom ents instead of replacing. It's actually in the wrong place, making it easy to miss. It was intended to add the entities the mod needs for Extinction mode. I modified the behavior to allow admins to set custom_ents in deathmatch and I had to make the new version not conflict with the old one. Using R1q2's override file in the engine might be better but if that one requires a full ent file for every customization then it's no different than what we have in the mod.

With the exception of the TagMalloc call inside the read file loop, I actually like the code in g_ent.c better, two nice tight functs, not the jumpy mess in g_team.c. The old stuff allocates 1 block for the entire file, the new one calls TagMalloc for every entity in the file. At least it only happens once per map.


Sun, 04 June 2006 2:14 pm
Profile YIM WWW
WOS Member
User avatar

Joined: Sat, 16 August 2003 4:41 pm
Posts: 1436
Location: New Jersey, USA
Post 
sweet. great job :)

_________________
Image
Chris
http://skies.clanwos.org/index.html


Sun, 04 June 2006 5:45 pm
Profile ICQ YIM WWW
Administrator
User avatar

Joined: Sat, 20 July 2002 4:14 am
Posts: 2695
Location: OR, USA
Post 
Oh, so very nicely done, Wabster.


I compiled the magical code and installed a new linux binary on my now re-enabled LOX Meet 'n Greet (removed the Phlem part of the name) and it works very well. The only thing I noticed is that the proximity of the messaging that comes up is wide enough that it will give multiple readings when many offworld teleport parts are close together. I do not consider this to be a problem with the code, but rather a call for me to move the pads farther apart in my entity files, which I will proceed to do shortly, as I intend to make this part of our little swarm-fest this weekend.

Feel free to check out the new feature on the Meet 'n Greet (phlem.ath.cx). I have silitex2 and q2dm1 entity files updated and am working on a couple more now.

:lol: :lol:


Mon, 05 June 2006 6:39 pm
Profile YIM
Administrator
User avatar

Joined: Sat, 20 July 2002 4:14 am
Posts: 2695
Location: OR, USA
Post 
Offworld teleport pads for Silitex2 and Q2DM1 maps have been repositioned to eliminate the Noise problem. Teleporter pointing to defunct servers have been purged. More destinations will be added in anticipation of the upcoming Swarm event. Reminder: server is at phlem.ath.cx:27910


Mon, 05 June 2006 8:44 pm
Profile YIM
WDL
User avatar

Joined: Sat, 20 July 2002 10:33 am
Posts: 3814
Location: Narnia
Post 
Just gave it a little test run and from my end it's working awesome! The names all pop up clearly and give the audible to let you know, very cool stuff. :) Can't wait to use it for the swarm :D

Great work QW and Phlem!

_________________
.-= Clan WOS - LOXophilia Server Status - LOX Downloads =-.


Mon, 05 June 2006 9:08 pm
Profile WWW
WDL
User avatar

Joined: Tue, 24 September 2002 4:02 pm
Posts: 3420
Location: So. California
Post Re: Entity file entries for off-world transporting
This is the latest version of the teleport code. This used most all your suggestions about text beforehand so you have some idea of where you are going before you make the leap. I couldn't think of an easy way to implement Skies' suggestion for a time delay, so teleport is immediate when you touch the pad, same as it would be on any normal teleport. Timing should not be a problem if the pads are located in out-of-the way places.

g_offworld.c
Code:
//****************************************************
//      Offworld Teleports
//****************************************************

//
// Original concept and code by Phlem<WOS> 08/29/2005
// Spawn function and revisions by QwazyWabbit<WOS> 06/03/2006
//

#include "g_local.h"
#include "g_team.h"

/*
To use this module:

  Add the spawn function pointer to g_spawn.c:
 
  In the prototype list:
  void SP_misc_offworld_teleporter (edict_t *self);   
   
  In the spawn function hash at spawn_t spawns[], add:
  {"misc_offworld_teleporter", SP_misc_offworld_teleporter},
    
  Everything else in this module is private.
*/

void offworld_teleporter_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
{
   
   //=================================================================================
   //  offworld_teleporter_touch - Expanded to include transporting to other servers
   //
   // Working implementation summary:
   //
   // 1 - User creates map with teleporter target set to special syntax:
   //
   //
   //   example:    q2@67.15.20.10:27910
   //
   //        where:  "q2@" indicates that this is an external q2 server
   //                "67.15.20.10:27910" indicates the IP address (or DNS name)
   //                     and port number of external server
   //
   // 2 - For good behavior on systems not supporting this feature, always
   //     include a teleport destination pad with same label.  This can be
   //     hidden or simply placed in a back room of the map to take it out of view.
   //
   // 3 - Supports launching of other game types, based on environment variables:
   //   
   //      q3    indicates a Quake3 game - Env Variable Q3_LAUNCHER will send appropriate
   //               launch command
   //
   //      hl    indicates a Half-Life game - Env Variable is HL_LAUNCHER
   //
   //      h2    indicates a Half-Life 2 game - Env Variable is H2_LAUNCHER
   //
   //      bf    indicates a BF1942 Server - Env Variable is BF_LAUNCHER
   //
   //      b2    BF2 Server - Env is B2_LAUNCHER
   //
   //      ef    Elite Force Server - Env is EF_LAUNCHER
   //   
   //      e2     Elite Force 2 Server - Env is E2_LAUNCHER
   //   
   //      u9    Unreal 99 Server - Env is U9_LAUNCHER
   //
   // 4 - If game is NON-Q2, the current Q2 game will be exited just after spawning
   //     of sub-process to start external game.
   //
   // 5 - A "I went to Server X" message is displayed in-game just prior to launch.
   //
   // NOTE: Code for non-Q2 games is still in progress.
   //
   //=================================================================================
   
   int         i, j, k;
    char      external_server[80];
    char      exit_message[80];
    char      connect_message[120];
   
      if (!other->client) // touched by someone we don't know :)
      return;
   
   Com_sprintf(external_server, sizeof(external_server), "%s", self->target);
   
   if (strstr(external_server, "q2@") != NULL)  // we have a match for remote q2 server
   {
      i = sprintf(exit_message, "say Offworld transport to %s ...\n", external_server);
      stuffcmd(other, exit_message);
      k = strlen(external_server);
      
      for ( j = 3 ; j < k ; j++)
         external_server[j-3] = external_server[j];
      
      external_server[k-3] = 0;
      Com_sprintf(connect_message, sizeof(connect_message), "connect %s\n", external_server);
      stuffcmd(other, connect_message);
   }
   
   //
   // handling for other games would go here
   //
   
   // catch any target format problems here
   else
   {
      gi.cprintf(other, PRINT_HIGH, "Server target format error.\n");
      return;
   }
}

// the wait time has passed, so set back up for another activation
void pad_wait (edict_t *ent)
{
   ent->nextthink = 0;
}

void offworld_teleporter_approach (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
{
   if (!other->client)
      return;      // not a player
   
   if (self->nextthink)
      return;      // already been triggered
   
    gi.centerprintf(other, self->message);
   gi.sound (other, CHAN_AUTO, gi.soundindex ("misc/talk1.wav"), 1, ATTN_NORM, 0);
   
   if (self->wait > 0)   
   {
      self->think = pad_wait;
      self->nextthink = level.time + self->wait;
   }
   else
   {   // we can't just remove (self) here, because this is a touch function
      // called while looping through area links...
      self->touch = NULL;
      self->nextthink = level.time + FRAMETIME;
      self->think = G_FreeEdict;
   }
}

/*QUAKED misc_offworld_teleporter (1 0 0) (-32 -32 -24) (32 32 -16)
Stepping onto this pad will teleport players to a different server.
*/

/* our new entity is built like this:
{
"message" "Offworld transport to\nLOXophilia\n(67.15.20.10:27910)"
"wait" "3"
"sounds" "2"
"target" "q2@67.15.20.10"
"origin" "576 736 116"
"classname" "misc_offworld_teleporter"
}
*/

void SP_misc_teleporter_offworld (edict_t *ent)
{
   edict_t      *trig, *trig1;
   
   if (!ent->target || !ent->message)
   {
      gi.dprintf ("Teleporter is missing target or message %s %s %s.\n", ent->classname, ent->target, ent->message);
      G_FreeEdict (ent);
      return;
   }
   
   gi.setmodel (ent, "models/objects/dmspot/tris.md2");
   ent->s.skinnum = 1;
   ent->s.effects = EF_TELEPORTER | EF_ROTATE; // obviously different pads
   ent->s.sound = gi.soundindex ("world/amb10.wav");
   ent->solid = SOLID_BBOX;
   
   VectorSet (ent->mins, -32, -32, -24);
   VectorSet (ent->maxs, 32, 32, -16);
   gi.linkentity (ent);
   
   // create the notification zone around the pad
   trig = G_Spawn ();
   trig->touch = offworld_teleporter_approach;
   trig->solid = SOLID_TRIGGER;
   trig->target = ent->target; // the target game and IP
   trig->owner = ent;
   trig->message = ent->message; //the text message to send
   if (!ent->sounds)
      ent->sounds = 2;
   trig->sounds = ent->sounds;
   if (!ent->wait)
      ent->wait = 3;
   trig->wait = ent->wait;
   trig->classname = "trigger_multiple";
   
   VectorCopy (ent->s.origin, trig->s.origin);
   VectorSet (trig->mins, -120, -120, 8);   // boundaries for the touch planes
   VectorSet (trig->maxs, 120, 120, 24);
   gi.linkentity (trig);
   
   // create the touch zone on the pad
   trig1 = G_Spawn ();
   trig1->touch = offworld_teleporter_touch;
   trig1->solid = SOLID_TRIGGER ;
   trig1->target = ent->target; // the target game and IP
   trig1->message = ent->message; //the text message to send
   trig1->owner = ent;
   trig1->classname = ent->classname;
   
   VectorCopy (ent->s.origin, trig1->s.origin);
   VectorSet (trig1->mins, -8, -8, 8);
   VectorSet (trig1->maxs, 8, 8, 24);
   gi.linkentity (trig1);
   
}


Sun, 07 February 2010 4:47 pm
Profile YIM WWW
WDL
User avatar

Joined: Tue, 24 September 2002 4:02 pm
Posts: 3420
Location: So. California
Post Re: Entity file entries for off-world transporting
g_ent.c

Code:
//****************************************************
//      Entity File Support
//****************************************************

//
// This code locates and loads .ent files.
// The files are located in the entfiles/ folder in the
// quake2 tree named after the map they modify.
// Map name: mapname.bsp, entfile: mapname.ent
// Use entdump to extract entities and modify them as needed.
//

#include "g_local.h"

static char *ReadEntFile(char *filename)
{
   
   FILE      *fp;
   char      *filestring = NULL;
   long int   i = 0;
   int         ch;
   
   for (;;)
   {
      fp = fopen(filename, "r");
      if (!fp) break;
      
      for (i=0; (ch = fgetc(fp)) != EOF; i++);
      
      filestring = gi.TagMalloc(i+1, TAG_LEVEL);
      if (!filestring) break;
      
      fseek(fp, 0, SEEK_SET);
      for (i=0; (ch = fgetc(fp)) != EOF; i++)
         filestring[i] = (char) ch;
      filestring[i] = '\0';
      break;
   }
   
   if (fp) fclose(fp);
   return(filestring);
}

//
// Called from within SpawnEntities() immediately before the entity parse loop
//       entities = LoadEntFile(mapname, entities);/*MrG{DRGN} 10/04/2004*/
//
char *LoadEntFile(char *mapname, char *entities)
{
   char   entfilename[MAX_QPATH] = "";
   char   *newentities;
   int      i;
   
   sprintf(entfilename, "entfiles/%s.ent", mapname);
   // convert string to all lowercase (for Linux)
   for (i = 0; entfilename[i]; i++)
      entfilename[i] = (char) tolower(entfilename[i]);
   
   newentities = ReadEntFile(entfilename);
   
   if (newentities)
   {   //leave these dprints active they show up in the server init console section
      gi.dprintf("Entity file %s.ent found\n", mapname);
      return(newentities);   // reassign the ents
   }
   else
   {
      gi.dprintf("No .ent File for %s.bsp\n", mapname);
      return(entities);
   }
}


Sun, 07 February 2010 5:11 pm
Profile YIM WWW
Administrator
User avatar

Joined: Sat, 20 July 2002 4:14 am
Posts: 2695
Location: OR, USA
Post Re: Entity file entries for off-world transporting
Very nice improvements there, QW.

On the Phlem Phront, I am trying to get a build going using MS Dev Studio 2005 ... just fighting some update crap now, but the code itself does not appear to be an issue so far ...

- P


Mon, 08 February 2010 11:32 am
Profile YIM
WDL
User avatar

Joined: Tue, 24 September 2002 4:02 pm
Posts: 3420
Location: So. California
Post Re: Entity file entries for off-world transporting
Yeah, the hardest part is dealing with warnings about deprecated/unsafe functions. By the time you get done smoothing out 2005 you will be upgrading to 2008 and worrying about catching up to 2010.

One of my favorite (not) gcc warnings is the one about no newline at end of file. Damn fussy.


Mon, 08 February 2010 6:19 pm
Profile YIM WWW
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 29 posts ]  Go to page Previous  1, 2


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron

Powered by phpBB © phpBB Group.
Style designed by Vjacheslav Trushkin