Annotation of quake2/game/g_spawn.c, revision 1.1

1.1     ! root        1: 
        !             2: #include "g_local.h"
        !             3: 
        !             4: typedef struct
        !             5: {
        !             6:        char    *name;
        !             7:        void    (*spawn)(edict_t *ent);
        !             8: } spawn_t;
        !             9: 
        !            10: 
        !            11: void SP_item_health (edict_t *self);
        !            12: void SP_item_health_small (edict_t *self);
        !            13: void SP_item_health_large (edict_t *self);
        !            14: void SP_item_health_mega (edict_t *self);
        !            15: 
        !            16: void SP_info_player_start (edict_t *ent);
        !            17: void SP_info_player_deathmatch (edict_t *ent);
        !            18: void SP_info_player_coop (edict_t *ent);
        !            19: void SP_info_player_intermission (edict_t *ent);
        !            20: 
        !            21: void SP_func_plat (edict_t *ent);
        !            22: void SP_func_rotating (edict_t *ent);
        !            23: void SP_func_button (edict_t *ent);
        !            24: void SP_func_door (edict_t *ent);
        !            25: void SP_func_door_secret (edict_t *ent);
        !            26: void SP_func_door_rotating (edict_t *ent);
        !            27: void SP_func_water (edict_t *ent);
        !            28: void SP_func_train (edict_t *ent);
        !            29: void SP_func_conveyor (edict_t *self);
        !            30: void SP_func_wall (edict_t *self);
        !            31: void SP_func_object (edict_t *self);
        !            32: void SP_func_explosive (edict_t *self);
        !            33: void SP_func_timer (edict_t *self);
        !            34: void SP_func_areaportal (edict_t *ent);
        !            35: void SP_func_clock (edict_t *ent);
        !            36: void SP_func_killbox (edict_t *ent);
        !            37: 
        !            38: void SP_trigger_always (edict_t *ent);
        !            39: void SP_trigger_once (edict_t *ent);
        !            40: void SP_trigger_multiple (edict_t *ent);
        !            41: void SP_trigger_relay (edict_t *ent);
        !            42: void SP_trigger_push (edict_t *ent);
        !            43: void SP_trigger_hurt (edict_t *ent);
        !            44: void SP_trigger_key (edict_t *ent);
        !            45: void SP_trigger_counter (edict_t *ent);
        !            46: void SP_trigger_elevator (edict_t *ent);
        !            47: void SP_trigger_gravity (edict_t *ent);
        !            48: void SP_trigger_monsterjump (edict_t *ent);
        !            49: 
        !            50: void SP_target_temp_entity (edict_t *ent);
        !            51: void SP_target_speaker (edict_t *ent);
        !            52: void SP_target_explosion (edict_t *ent);
        !            53: void SP_target_changelevel (edict_t *ent);
        !            54: void SP_target_secret (edict_t *ent);
        !            55: void SP_target_goal (edict_t *ent);
        !            56: void SP_target_splash (edict_t *ent);
        !            57: void SP_target_spawner (edict_t *ent);
        !            58: void SP_target_blaster (edict_t *ent);
        !            59: void SP_target_crosslevel_trigger (edict_t *ent);
        !            60: void SP_target_crosslevel_target (edict_t *ent);
        !            61: void SP_target_laser (edict_t *self);
        !            62: void SP_target_help (edict_t *ent);
        !            63: void SP_target_actor (edict_t *ent);
        !            64: void SP_target_lightramp (edict_t *self);
        !            65: void SP_target_earthquake (edict_t *ent);
        !            66: void SP_target_character (edict_t *ent);
        !            67: void SP_target_string (edict_t *ent);
        !            68: 
        !            69: void SP_worldspawn (edict_t *ent);
        !            70: void SP_viewthing (edict_t *ent);
        !            71: 
        !            72: void SP_light (edict_t *self);
        !            73: void SP_light_mine1 (edict_t *ent);
        !            74: void SP_light_mine2 (edict_t *ent);
        !            75: void SP_info_null (edict_t *self);
        !            76: void SP_info_notnull (edict_t *self);
        !            77: void SP_path_corner (edict_t *self);
        !            78: void SP_point_combat (edict_t *self);
        !            79: 
        !            80: void SP_misc_explobox (edict_t *self);
        !            81: void SP_misc_banner (edict_t *self);
        !            82: void SP_misc_satellite_dish (edict_t *self);
        !            83: void SP_misc_actor (edict_t *self);
        !            84: void SP_misc_gib_arm (edict_t *self);
        !            85: void SP_misc_gib_leg (edict_t *self);
        !            86: void SP_misc_gib_head (edict_t *self);
        !            87: void SP_misc_insane (edict_t *self);
        !            88: void SP_misc_deadsoldier (edict_t *self);
        !            89: void SP_misc_viper (edict_t *self);
        !            90: void SP_misc_viper_bomb (edict_t *self);
        !            91: void SP_misc_bigviper (edict_t *self);
        !            92: void SP_misc_strogg_ship (edict_t *self);
        !            93: void SP_misc_teleporter (edict_t *self);
        !            94: void SP_misc_teleporter_dest (edict_t *self);
        !            95: void SP_misc_blackhole (edict_t *self);
        !            96: void SP_misc_eastertank (edict_t *self);
        !            97: void SP_misc_easterchick (edict_t *self);
        !            98: void SP_misc_easterchick2 (edict_t *self);
        !            99: 
        !           100: void SP_monster_berserk (edict_t *self);
        !           101: void SP_monster_gladiator (edict_t *self);
        !           102: void SP_monster_gunner (edict_t *self);
        !           103: void SP_monster_infantry (edict_t *self);
        !           104: void SP_monster_soldier_light (edict_t *self);
        !           105: void SP_monster_soldier (edict_t *self);
        !           106: void SP_monster_soldier_ss (edict_t *self);
        !           107: void SP_monster_tank (edict_t *self);
        !           108: void SP_monster_medic (edict_t *self);
        !           109: void SP_monster_flipper (edict_t *self);
        !           110: void SP_monster_chick (edict_t *self);
        !           111: void SP_monster_parasite (edict_t *self);
        !           112: void SP_monster_flyer (edict_t *self);
        !           113: void SP_monster_brain (edict_t *self);
        !           114: void SP_monster_floater (edict_t *self);
        !           115: void SP_monster_hover (edict_t *self);
        !           116: void SP_monster_mutant (edict_t *self);
        !           117: void SP_monster_supertank (edict_t *self);
        !           118: void SP_monster_boss2 (edict_t *self);
        !           119: void SP_monster_jorg (edict_t *self);
        !           120: void SP_monster_boss3_stand (edict_t *self);
        !           121: 
        !           122: void SP_monster_commander_body (edict_t *self);
        !           123: 
        !           124: void SP_turret_breach (edict_t *self);
        !           125: void SP_turret_base (edict_t *self);
        !           126: void SP_turret_driver (edict_t *self);
        !           127: 
        !           128: 
        !           129: spawn_t        spawns[] = {
        !           130:        {"item_health", SP_item_health},
        !           131:        {"item_health_small", SP_item_health_small},
        !           132:        {"item_health_large", SP_item_health_large},
        !           133:        {"item_health_mega", SP_item_health_mega},
        !           134: 
        !           135:        {"info_player_start", SP_info_player_start},
        !           136:        {"info_player_deathmatch", SP_info_player_deathmatch},
        !           137:        {"info_player_coop", SP_info_player_coop},
        !           138:        {"info_player_intermission", SP_info_player_intermission},
        !           139: 
        !           140:        {"func_plat", SP_func_plat},
        !           141:        {"func_button", SP_func_button},
        !           142:        {"func_door", SP_func_door},
        !           143:        {"func_door_secret", SP_func_door_secret},
        !           144:        {"func_door_rotating", SP_func_door_rotating},
        !           145:        {"func_rotating", SP_func_rotating},
        !           146:        {"func_train", SP_func_train},
        !           147:        {"func_water", SP_func_water},
        !           148:        {"func_conveyor", SP_func_conveyor},
        !           149:        {"func_areaportal", SP_func_areaportal},
        !           150:        {"func_clock", SP_func_clock},
        !           151:        {"func_wall", SP_func_wall},
        !           152:        {"func_object", SP_func_object},
        !           153:        {"func_timer", SP_func_timer},
        !           154:        {"func_explosive", SP_func_explosive},
        !           155:        {"func_killbox", SP_func_killbox},
        !           156: 
        !           157:        {"trigger_always", SP_trigger_always},
        !           158:        {"trigger_once", SP_trigger_once},
        !           159:        {"trigger_multiple", SP_trigger_multiple},
        !           160:        {"trigger_relay", SP_trigger_relay},
        !           161:        {"trigger_push", SP_trigger_push},
        !           162:        {"trigger_hurt", SP_trigger_hurt},
        !           163:        {"trigger_key", SP_trigger_key},
        !           164:        {"trigger_counter", SP_trigger_counter},
        !           165:        {"trigger_elevator", SP_trigger_elevator},
        !           166:        {"trigger_gravity", SP_trigger_gravity},
        !           167:        {"trigger_monsterjump", SP_trigger_monsterjump},
        !           168: 
        !           169:        {"target_temp_entity", SP_target_temp_entity},
        !           170:        {"target_speaker", SP_target_speaker},
        !           171:        {"target_explosion", SP_target_explosion},
        !           172:        {"target_changelevel", SP_target_changelevel},
        !           173:        {"target_secret", SP_target_secret},
        !           174:        {"target_goal", SP_target_goal},
        !           175:        {"target_splash", SP_target_splash},
        !           176:        {"target_spawner", SP_target_spawner},
        !           177:        {"target_blaster", SP_target_blaster},
        !           178:        {"target_crosslevel_trigger", SP_target_crosslevel_trigger},
        !           179:        {"target_crosslevel_target", SP_target_crosslevel_target},
        !           180:        {"target_laser", SP_target_laser},
        !           181:        {"target_help", SP_target_help},
        !           182:        {"target_actor", SP_target_actor},
        !           183:        {"target_lightramp", SP_target_lightramp},
        !           184:        {"target_earthquake", SP_target_earthquake},
        !           185:        {"target_character", SP_target_character},
        !           186:        {"target_string", SP_target_string},
        !           187: 
        !           188:        {"worldspawn", SP_worldspawn},
        !           189:        {"viewthing", SP_viewthing},
        !           190: 
        !           191:        {"light", SP_light},
        !           192:        {"light_mine1", SP_light_mine1},
        !           193:        {"light_mine2", SP_light_mine2},
        !           194:        {"info_null", SP_info_null},
        !           195:        {"func_group", SP_info_null},
        !           196:        {"info_notnull", SP_info_notnull},
        !           197:        {"path_corner", SP_path_corner},
        !           198:        {"point_combat", SP_point_combat},
        !           199: 
        !           200:        {"misc_explobox", SP_misc_explobox},
        !           201:        {"misc_banner", SP_misc_banner},
        !           202:        {"misc_satellite_dish", SP_misc_satellite_dish},
        !           203:        {"misc_actor", SP_misc_actor},
        !           204:        {"misc_gib_arm", SP_misc_gib_arm},
        !           205:        {"misc_gib_leg", SP_misc_gib_leg},
        !           206:        {"misc_gib_head", SP_misc_gib_head},
        !           207:        {"misc_insane", SP_misc_insane},
        !           208:        {"misc_deadsoldier", SP_misc_deadsoldier},
        !           209:        {"misc_viper", SP_misc_viper},
        !           210:        {"misc_viper_bomb", SP_misc_viper_bomb},
        !           211:        {"misc_bigviper", SP_misc_bigviper},
        !           212:        {"misc_strogg_ship", SP_misc_strogg_ship},
        !           213:        {"misc_teleporter", SP_misc_teleporter},
        !           214:        {"misc_teleporter_dest", SP_misc_teleporter_dest},
        !           215:        {"misc_blackhole", SP_misc_blackhole},
        !           216:        {"misc_eastertank", SP_misc_eastertank},
        !           217:        {"misc_easterchick", SP_misc_easterchick},
        !           218:        {"misc_easterchick2", SP_misc_easterchick2},
        !           219: 
        !           220:        {"monster_berserk", SP_monster_berserk},
        !           221:        {"monster_gladiator", SP_monster_gladiator},
        !           222:        {"monster_gunner", SP_monster_gunner},
        !           223:        {"monster_infantry", SP_monster_infantry},
        !           224:        {"monster_soldier_light", SP_monster_soldier_light},
        !           225:        {"monster_soldier", SP_monster_soldier},
        !           226:        {"monster_soldier_ss", SP_monster_soldier_ss},
        !           227:        {"monster_tank", SP_monster_tank},
        !           228:        {"monster_tank_commander", SP_monster_tank},
        !           229:        {"monster_medic", SP_monster_medic},
        !           230:        {"monster_flipper", SP_monster_flipper},
        !           231:        {"monster_chick", SP_monster_chick},
        !           232:        {"monster_parasite", SP_monster_parasite},
        !           233:        {"monster_flyer", SP_monster_flyer},
        !           234:        {"monster_brain", SP_monster_brain},
        !           235:        {"monster_floater", SP_monster_floater},
        !           236:        {"monster_hover", SP_monster_hover},
        !           237:        {"monster_mutant", SP_monster_mutant},
        !           238:        {"monster_supertank", SP_monster_supertank},
        !           239:        {"monster_boss2", SP_monster_boss2},
        !           240:        {"monster_boss3_stand", SP_monster_boss3_stand},
        !           241:        {"monster_jorg", SP_monster_jorg},
        !           242: 
        !           243:        {"monster_commander_body", SP_monster_commander_body},
        !           244: 
        !           245:        {"turret_breach", SP_turret_breach},
        !           246:        {"turret_base", SP_turret_base},
        !           247:        {"turret_driver", SP_turret_driver},
        !           248: 
        !           249:        {NULL, NULL}
        !           250: };
        !           251: 
        !           252: /*
        !           253: ===============
        !           254: ED_CallSpawn
        !           255: 
        !           256: Finds the spawn function for the entity and calls it
        !           257: ===============
        !           258: */
        !           259: void ED_CallSpawn (edict_t *ent)
        !           260: {
        !           261:        spawn_t *s;
        !           262:        gitem_t *item;
        !           263:        int             i;
        !           264: 
        !           265:        if (!ent->classname)
        !           266:        {
        !           267:                gi.dprintf ("ED_CallSpawn: NULL classname\n");
        !           268:                return;
        !           269:        }
        !           270: 
        !           271:        // check item spawn functions
        !           272:        for (i=0,item=itemlist ; i<game.num_items ; i++,item++)
        !           273:        {
        !           274:                if (!item->classname)
        !           275:                        continue;
        !           276:                if (!strcmp(item->classname, ent->classname))
        !           277:                {       // found it
        !           278:                        SpawnItem (ent, item);
        !           279:                        return;
        !           280:                }
        !           281:        }
        !           282: 
        !           283:        // check normal spawn functions
        !           284:        for (s=spawns ; s->name ; s++)
        !           285:        {
        !           286:                if (!strcmp(s->name, ent->classname))
        !           287:                {       // found it
        !           288:                        s->spawn (ent);
        !           289:                        return;
        !           290:                }
        !           291:        }
        !           292:        gi.dprintf ("%s doesn't have a spawn function\n", ent->classname);
        !           293: }
        !           294: 
        !           295: /*
        !           296: =============
        !           297: ED_NewString
        !           298: =============
        !           299: */
        !           300: char *ED_NewString (char *string)
        !           301: {
        !           302:        char    *newb, *new_p;
        !           303:        int             i,l;
        !           304:        
        !           305:        l = strlen(string) + 1;
        !           306: 
        !           307:        newb = gi.TagMalloc (l, TAG_LEVEL);
        !           308: 
        !           309:        new_p = newb;
        !           310: 
        !           311:        for (i=0 ; i< l ; i++)
        !           312:        {
        !           313:                if (string[i] == '\\' && i < l-1)
        !           314:                {
        !           315:                        i++;
        !           316:                        if (string[i] == 'n')
        !           317:                                *new_p++ = '\n';
        !           318:                        else
        !           319:                                *new_p++ = '\\';
        !           320:                }
        !           321:                else
        !           322:                        *new_p++ = string[i];
        !           323:        }
        !           324:        
        !           325:        return newb;
        !           326: }
        !           327: 
        !           328: 
        !           329: 
        !           330: 
        !           331: /*
        !           332: ===============
        !           333: ED_ParseField
        !           334: 
        !           335: Takes a key/value pair and sets the binary values
        !           336: in an edict
        !           337: ===============
        !           338: */
        !           339: void ED_ParseField (char *key, char *value, edict_t *ent)
        !           340: {
        !           341:        field_t *f;
        !           342:        byte    *b;
        !           343:        float   v;
        !           344:        vec3_t  vec;
        !           345: 
        !           346:        for (f=fields ; f->name ; f++)
        !           347:        {
        !           348:                if (!Q_stricmp(f->name, key))
        !           349:                {       // found it
        !           350:                        if (f->flags & FFL_SPAWNTEMP)
        !           351:                                b = (byte *)&st;
        !           352:                        else
        !           353:                                b = (byte *)ent;
        !           354: 
        !           355:                        switch (f->type)
        !           356:                        {
        !           357:                        case F_LSTRING:
        !           358:                                *(char **)(b+f->ofs) = ED_NewString (value);
        !           359:                                break;
        !           360:                        case F_VECTOR:
        !           361:                                sscanf (value, "%f %f %f", &vec[0], &vec[1], &vec[2]);
        !           362:                                ((float *)(b+f->ofs))[0] = vec[0];
        !           363:                                ((float *)(b+f->ofs))[1] = vec[1];
        !           364:                                ((float *)(b+f->ofs))[2] = vec[2];
        !           365:                                break;
        !           366:                        case F_INT:
        !           367:                                *(int *)(b+f->ofs) = atoi(value);
        !           368:                                break;
        !           369:                        case F_FLOAT:
        !           370:                                *(float *)(b+f->ofs) = atof(value);
        !           371:                                break;
        !           372:                        case F_ANGLEHACK:
        !           373:                                v = atof(value);
        !           374:                                ((float *)(b+f->ofs))[0] = 0;
        !           375:                                ((float *)(b+f->ofs))[1] = v;
        !           376:                                ((float *)(b+f->ofs))[2] = 0;
        !           377:                                break;
        !           378:                        case F_IGNORE:
        !           379:                                break;
        !           380:                        }
        !           381:                        return;
        !           382:                }
        !           383:        }
        !           384:        gi.dprintf ("%s is not a field\n", key);
        !           385: }
        !           386: 
        !           387: /*
        !           388: ====================
        !           389: ED_ParseEdict
        !           390: 
        !           391: Parses an edict out of the given string, returning the new position
        !           392: ed should be a properly initialized empty edict.
        !           393: ====================
        !           394: */
        !           395: char *ED_ParseEdict (char *data, edict_t *ent)
        !           396: {
        !           397:        qboolean        init;
        !           398:        char            keyname[256];
        !           399:        char            *com_token;
        !           400: 
        !           401:        init = false;
        !           402:        memset (&st, 0, sizeof(st));
        !           403: 
        !           404: // go through all the dictionary pairs
        !           405:        while (1)
        !           406:        {       
        !           407:        // parse key
        !           408:                com_token = COM_Parse (&data);
        !           409:                if (com_token[0] == '}')
        !           410:                        break;
        !           411:                if (!data)
        !           412:                        gi.error ("ED_ParseEntity: EOF without closing brace");
        !           413: 
        !           414:                strncpy (keyname, com_token, sizeof(keyname)-1);
        !           415:                
        !           416:        // parse value  
        !           417:                com_token = COM_Parse (&data);
        !           418:                if (!data)
        !           419:                        gi.error ("ED_ParseEntity: EOF without closing brace");
        !           420: 
        !           421:                if (com_token[0] == '}')
        !           422:                        gi.error ("ED_ParseEntity: closing brace without data");
        !           423: 
        !           424:                init = true;    
        !           425: 
        !           426:        // keynames with a leading underscore are used for utility comments,
        !           427:        // and are immediately discarded by quake
        !           428:                if (keyname[0] == '_')
        !           429:                        continue;
        !           430: 
        !           431:                ED_ParseField (keyname, com_token, ent);
        !           432:        }
        !           433: 
        !           434:        if (!init)
        !           435:                memset (ent, 0, sizeof(*ent));
        !           436: 
        !           437:        return data;
        !           438: }
        !           439: 
        !           440: 
        !           441: /*
        !           442: ================
        !           443: G_FindTeams
        !           444: 
        !           445: Chain together all entities with a matching team field.
        !           446: 
        !           447: All but the first will have the FL_TEAMSLAVE flag set.
        !           448: All but the last will have the teamchain field set to the next one
        !           449: ================
        !           450: */
        !           451: void G_FindTeams (void)
        !           452: {
        !           453:        edict_t *e, *e2, *chain;
        !           454:        int             i, j;
        !           455:        int             c, c2;
        !           456: 
        !           457:        c = 0;
        !           458:        c2 = 0;
        !           459:        for (i=1, e=g_edicts+i ; i < globals.num_edicts ; i++,e++)
        !           460:        {
        !           461:                if (!e->inuse)
        !           462:                        continue;
        !           463:                if (!e->team)
        !           464:                        continue;
        !           465:                if (e->flags & FL_TEAMSLAVE)
        !           466:                        continue;
        !           467:                chain = e;
        !           468:                e->teammaster = e;
        !           469:                c++;
        !           470:                c2++;
        !           471:                for (j=i+1, e2=e+1 ; j < globals.num_edicts ; j++,e2++)
        !           472:                {
        !           473:                        if (!e2->inuse)
        !           474:                                continue;
        !           475:                        if (!e2->team)
        !           476:                                continue;
        !           477:                        if (e2->flags & FL_TEAMSLAVE)
        !           478:                                continue;
        !           479:                        if (!strcmp(e->team, e2->team))
        !           480:                        {
        !           481:                                c2++;
        !           482:                                chain->teamchain = e2;
        !           483:                                e2->teammaster = e;
        !           484:                                chain = e2;
        !           485:                                e2->flags |= FL_TEAMSLAVE;
        !           486:                        }
        !           487:                }
        !           488:        }
        !           489: 
        !           490:        gi.dprintf ("%i teams with %i entities\n", c, c2);
        !           491: }
        !           492: 
        !           493: /*
        !           494: ==============
        !           495: SpawnEntities
        !           496: 
        !           497: Creates a server's entity / program execution context by
        !           498: parsing textual entity definitions out of an ent file.
        !           499: ==============
        !           500: */
        !           501: void SpawnEntities (char *mapname, char *entities, char *spawnpoint)
        !           502: {
        !           503:        edict_t         *ent;
        !           504:        int                     inhibit;
        !           505:        char            *com_token;
        !           506:        int                     i;
        !           507:        float           skill_level;
        !           508: 
        !           509:        skill_level = floor (skill->value);
        !           510:        if (skill_level < 0)
        !           511:                skill_level = 0;
        !           512:        if (skill_level > 3)
        !           513:                skill_level = 3;
        !           514:        if (skill->value != skill_level)
        !           515:                gi.cvar_forceset("skill", va("%f", skill_level));
        !           516: 
        !           517:        SaveClientData ();
        !           518: 
        !           519:        gi.FreeTags (TAG_LEVEL);
        !           520: 
        !           521:        memset (&level, 0, sizeof(level));
        !           522:        memset (g_edicts, 0, game.maxentities * sizeof (g_edicts[0]));
        !           523: 
        !           524:        strncpy (level.mapname, mapname, sizeof(level.mapname)-1);
        !           525:        strncpy (game.spawnpoint, spawnpoint, sizeof(game.spawnpoint)-1);
        !           526: 
        !           527:        // set client fields on player ents
        !           528:        for (i=0 ; i<game.maxclients ; i++)
        !           529:                g_edicts[i+1].client = game.clients + i;
        !           530: 
        !           531:        ent = NULL;
        !           532:        inhibit = 0;
        !           533: 
        !           534: // parse ents
        !           535:        while (1)
        !           536:        {
        !           537:                // parse the opening brace      
        !           538:                com_token = COM_Parse (&entities);
        !           539:                if (!entities)
        !           540:                        break;
        !           541:                if (com_token[0] != '{')
        !           542:                        gi.error ("ED_LoadFromFile: found %s when expecting {",com_token);
        !           543: 
        !           544:                if (!ent)
        !           545:                        ent = g_edicts;
        !           546:                else
        !           547:                        ent = G_Spawn ();
        !           548:                entities = ED_ParseEdict (entities, ent);
        !           549: 
        !           550:                // yet another map hack
        !           551:                if (!stricmp(level.mapname, "command") && !stricmp(ent->classname, "trigger_once") && !stricmp(ent->model, "*27"))
        !           552:                        ent->spawnflags &= ~SPAWNFLAG_NOT_HARD;
        !           553: 
        !           554:                // remove things (except the world) from different skill levels or deathmatch
        !           555:                if (ent != g_edicts)
        !           556:                {
        !           557:                        if (deathmatch->value)
        !           558:                        {
        !           559:                                if ( ent->spawnflags & SPAWNFLAG_NOT_DEATHMATCH )
        !           560:                                {
        !           561:                                        G_FreeEdict (ent);      
        !           562:                                        inhibit++;
        !           563:                                        continue;
        !           564:                                }
        !           565:                        }
        !           566:                        else
        !           567:                        {
        !           568:                                if ( /* ((coop->value) && (ent->spawnflags & SPAWNFLAG_NOT_COOP)) || */
        !           569:                                        ((skill->value == 0) && (ent->spawnflags & SPAWNFLAG_NOT_EASY)) ||
        !           570:                                        ((skill->value == 1) && (ent->spawnflags & SPAWNFLAG_NOT_MEDIUM)) ||
        !           571:                                        (((skill->value == 2) || (skill->value == 3)) && (ent->spawnflags & SPAWNFLAG_NOT_HARD))
        !           572:                                        )
        !           573:                                        {
        !           574:                                                G_FreeEdict (ent);      
        !           575:                                                inhibit++;
        !           576:                                                continue;
        !           577:                                        }
        !           578:                        }
        !           579: 
        !           580:                        ent->spawnflags &= ~(SPAWNFLAG_NOT_EASY|SPAWNFLAG_NOT_MEDIUM|SPAWNFLAG_NOT_HARD|SPAWNFLAG_NOT_COOP|SPAWNFLAG_NOT_DEATHMATCH);
        !           581:                }
        !           582: 
        !           583:                ED_CallSpawn (ent);
        !           584:        }       
        !           585: 
        !           586:        gi.dprintf ("%i entities inhibited\n", inhibit);
        !           587: 
        !           588:        G_FindTeams ();
        !           589: 
        !           590:        PlayerTrail_Init ();
        !           591: }
        !           592: 
        !           593: 
        !           594: //===================================================================
        !           595: 
        !           596: #if 0
        !           597:        // cursor positioning
        !           598:        xl <value>
        !           599:        xr <value>
        !           600:        yb <value>
        !           601:        yt <value>
        !           602:        xv <value>
        !           603:        yv <value>
        !           604: 
        !           605:        // drawing
        !           606:        statpic <name>
        !           607:        pic <stat>
        !           608:        num <fieldwidth> <stat>
        !           609:        string <stat>
        !           610: 
        !           611:        // control
        !           612:        if <stat>
        !           613:        ifeq <stat> <value>
        !           614:        ifbit <stat> <value>
        !           615:        endif
        !           616: 
        !           617: #endif
        !           618: 
        !           619: char *single_statusbar = 
        !           620: "yb    -24 "
        !           621: 
        !           622: // health
        !           623: "xv    0 "
        !           624: "hnum "
        !           625: "xv    50 "
        !           626: "pic 0 "
        !           627: 
        !           628: // ammo
        !           629: "if 2 "
        !           630: "      xv      100 "
        !           631: "      anum "
        !           632: "      xv      150 "
        !           633: "      pic 2 "
        !           634: "endif "
        !           635: 
        !           636: // armor
        !           637: "if 4 "
        !           638: "      xv      200 "
        !           639: "      rnum "
        !           640: "      xv      250 "
        !           641: "      pic 4 "
        !           642: "endif "
        !           643: 
        !           644: // selected item
        !           645: "if 6 "
        !           646: "      xv      296 "
        !           647: "      pic 6 "
        !           648: "endif "
        !           649: 
        !           650: "yb    -50 "
        !           651: 
        !           652: // picked up item
        !           653: "if 7 "
        !           654: "      xv      0 "
        !           655: "      pic 7 "
        !           656: "      xv      26 "
        !           657: "      yb      -42 "
        !           658: "      stat_string 8 "
        !           659: "      yb      -50 "
        !           660: "endif "
        !           661: 
        !           662: // timer
        !           663: "if 9 "
        !           664: "      xv      262 "
        !           665: "      num     2       10 "
        !           666: "      xv      296 "
        !           667: "      pic     9 "
        !           668: "endif "
        !           669: 
        !           670: //  help / weapon icon 
        !           671: "if 11 "
        !           672: "      xv      148 "
        !           673: "      pic     11 "
        !           674: "endif "
        !           675: ;
        !           676: 
        !           677: char *dm_statusbar =
        !           678: "yb    -24 "
        !           679: 
        !           680: // health
        !           681: "xv    0 "
        !           682: "hnum "
        !           683: "xv    50 "
        !           684: "pic 0 "
        !           685: 
        !           686: // ammo
        !           687: "if 2 "
        !           688: "      xv      100 "
        !           689: "      anum "
        !           690: "      xv      150 "
        !           691: "      pic 2 "
        !           692: "endif "
        !           693: 
        !           694: // armor
        !           695: "if 4 "
        !           696: "      xv      200 "
        !           697: "      rnum "
        !           698: "      xv      250 "
        !           699: "      pic 4 "
        !           700: "endif "
        !           701: 
        !           702: // selected item
        !           703: "if 6 "
        !           704: "      xv      296 "
        !           705: "      pic 6 "
        !           706: "endif "
        !           707: 
        !           708: "yb    -50 "
        !           709: 
        !           710: // picked up item
        !           711: "if 7 "
        !           712: "      xv      0 "
        !           713: "      pic 7 "
        !           714: "      xv      26 "
        !           715: "      yb      -42 "
        !           716: "      stat_string 8 "
        !           717: "      yb      -50 "
        !           718: "endif "
        !           719: 
        !           720: // timer
        !           721: "if 9 "
        !           722: "      xv      246 "
        !           723: "      num     2       10 "
        !           724: "      xv      296 "
        !           725: "      pic     9 "
        !           726: "endif "
        !           727: 
        !           728: //  help / weapon icon 
        !           729: "if 11 "
        !           730: "      xv      148 "
        !           731: "      pic     11 "
        !           732: "endif "
        !           733: 
        !           734: //  frags
        !           735: "xr    -50 "
        !           736: "yt 2 "
        !           737: "num 3 14"
        !           738: ;
        !           739: 
        !           740: 
        !           741: /*QUAKED worldspawn (0 0 0) ?
        !           742: 
        !           743: Only used for the world.
        !           744: "sky"  environment map name
        !           745: "skyaxis"      vector axis for rotating sky
        !           746: "skyrotate"    speed of rotation in degrees/second
        !           747: "sounds"       music cd track number
        !           748: "gravity"      800 is default gravity
        !           749: "message"      text to print at user logon
        !           750: */
        !           751: void SP_worldspawn (edict_t *ent)
        !           752: {
        !           753:        ent->movetype = MOVETYPE_PUSH;
        !           754:        ent->solid = SOLID_BSP;
        !           755:        ent->inuse = true;                      // since the world doesn't use G_Spawn()
        !           756:        ent->s.modelindex = 1;          // world model is always index 1
        !           757: 
        !           758:        //---------------
        !           759: 
        !           760:        // reserve some spots for dead player bodies for coop / deathmatch
        !           761:        InitBodyQue ();
        !           762: 
        !           763:        // set configstrings for items
        !           764:        SetItemNames ();
        !           765: 
        !           766:        if (st.nextmap)
        !           767:                strcpy (level.nextmap, st.nextmap);
        !           768: 
        !           769:        // make some data visible to the server
        !           770: 
        !           771:        if (ent->message && ent->message[0])
        !           772:        {
        !           773:                gi.configstring (CS_NAME, ent->message);
        !           774:                strncpy (level.level_name, ent->message, sizeof(level.level_name));
        !           775:        }
        !           776:        else
        !           777:                strncpy (level.level_name, level.mapname, sizeof(level.level_name));
        !           778: 
        !           779:        if (st.sky && st.sky[0])
        !           780:                gi.configstring (CS_SKY, st.sky);
        !           781:        else
        !           782:                gi.configstring (CS_SKY, "unit1_");
        !           783: 
        !           784:        gi.configstring (CS_SKYROTATE, va("%f", st.skyrotate) );
        !           785: 
        !           786:        gi.configstring (CS_SKYAXIS, va("%f %f %f",
        !           787:                st.skyaxis[0], st.skyaxis[1], st.skyaxis[2]) );
        !           788: 
        !           789:        gi.configstring (CS_CDTRACK, va("%i", ent->sounds) );
        !           790: 
        !           791:        gi.configstring (CS_MAXCLIENTS, va("%i", (int)(maxclients->value) ) );
        !           792: 
        !           793:        // status bar program
        !           794:        if (deathmatch->value)
        !           795:                gi.configstring (CS_STATUSBAR, dm_statusbar);
        !           796:        else
        !           797:                gi.configstring (CS_STATUSBAR, single_statusbar);
        !           798: 
        !           799:        //---------------
        !           800: 
        !           801: 
        !           802:        // help icon for statusbar
        !           803:        gi.imageindex ("i_help");
        !           804:        level.pic_health = gi.imageindex ("i_health");
        !           805:        gi.imageindex ("help");
        !           806:        gi.imageindex ("field_3");
        !           807: 
        !           808:        if (!st.gravity)
        !           809:                gi.cvar_set("sv_gravity", "800");
        !           810:        else
        !           811:                gi.cvar_set("sv_gravity", st.gravity);
        !           812: 
        !           813:        snd_fry = gi.soundindex ("player/fry.wav");     // standing in lava / slime
        !           814: 
        !           815:        PrecacheItem (FindItem ("Blaster"));
        !           816: 
        !           817:        gi.soundindex ("player/lava1.wav");
        !           818:        gi.soundindex ("player/lava2.wav");
        !           819: 
        !           820:        gi.soundindex ("misc/pc_up.wav");
        !           821:        gi.soundindex ("misc/talk1.wav");
        !           822: 
        !           823:        gi.soundindex ("misc/udeath.wav");
        !           824: 
        !           825:        // gibs
        !           826:        gi.soundindex ("items/respawn1.wav");
        !           827: 
        !           828:        // sexed sounds
        !           829:        gi.soundindex ("*death1.wav");
        !           830:        gi.soundindex ("*death2.wav");
        !           831:        gi.soundindex ("*death3.wav");
        !           832:        gi.soundindex ("*death4.wav");
        !           833:        gi.soundindex ("*fall1.wav");
        !           834:        gi.soundindex ("*fall2.wav");   
        !           835:        gi.soundindex ("*gurp1.wav");           // drowning damage
        !           836:        gi.soundindex ("*gurp2.wav");   
        !           837:        gi.soundindex ("*jump1.wav");           // player jump
        !           838:        gi.soundindex ("*pain25_1.wav");
        !           839:        gi.soundindex ("*pain25_2.wav");
        !           840:        gi.soundindex ("*pain50_1.wav");
        !           841:        gi.soundindex ("*pain50_2.wav");
        !           842:        gi.soundindex ("*pain75_1.wav");
        !           843:        gi.soundindex ("*pain75_2.wav");
        !           844:        gi.soundindex ("*pain100_1.wav");
        !           845:        gi.soundindex ("*pain100_2.wav");
        !           846: 
        !           847:        //-------------------
        !           848: 
        !           849:        gi.soundindex ("player/gasp1.wav");             // gasping for air
        !           850:        gi.soundindex ("player/gasp2.wav");             // head breaking surface, not gasping
        !           851: 
        !           852:        gi.soundindex ("player/watr_in.wav");   // feet hitting water
        !           853:        gi.soundindex ("player/watr_out.wav");  // feet leaving water
        !           854: 
        !           855:        gi.soundindex ("player/watr_un.wav");   // head going underwater
        !           856:        
        !           857:        gi.soundindex ("player/u_breath1.wav");
        !           858:        gi.soundindex ("player/u_breath2.wav");
        !           859: 
        !           860:        gi.soundindex ("items/pkup.wav");               // bonus item pickup
        !           861:        gi.soundindex ("world/land.wav");               // landing thud
        !           862:        gi.soundindex ("misc/h2ohit1.wav");             // landing splash
        !           863: 
        !           864:        gi.soundindex ("items/damage.wav");
        !           865:        gi.soundindex ("items/protect.wav");
        !           866:        gi.soundindex ("items/protect4.wav");
        !           867:        gi.soundindex ("weapons/noammo.wav");
        !           868: 
        !           869:        gi.soundindex ("infantry/inflies1.wav");
        !           870: 
        !           871:        sm_meat_index = gi.modelindex ("models/objects/gibs/sm_meat/tris.md2");
        !           872:        gi.modelindex ("models/objects/gibs/arm/tris.md2");
        !           873:        gi.modelindex ("models/objects/gibs/bone/tris.md2");
        !           874:        gi.modelindex ("models/objects/gibs/bone2/tris.md2");
        !           875:        gi.modelindex ("models/objects/gibs/chest/tris.md2");
        !           876:        gi.modelindex ("models/objects/gibs/skull/tris.md2");
        !           877:        gi.modelindex ("models/objects/gibs/head2/tris.md2");
        !           878: 
        !           879: //
        !           880: // Setup light animation tables. 'a' is total darkness, 'z' is doublebright.
        !           881: //
        !           882: 
        !           883:        // 0 normal
        !           884:        gi.configstring(CS_LIGHTS+0, "m");
        !           885:        
        !           886:        // 1 FLICKER (first variety)
        !           887:        gi.configstring(CS_LIGHTS+1, "mmnmmommommnonmmonqnmmo");
        !           888:        
        !           889:        // 2 SLOW STRONG PULSE
        !           890:        gi.configstring(CS_LIGHTS+2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
        !           891:        
        !           892:        // 3 CANDLE (first variety)
        !           893:        gi.configstring(CS_LIGHTS+3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
        !           894:        
        !           895:        // 4 FAST STROBE
        !           896:        gi.configstring(CS_LIGHTS+4, "mamamamamama");
        !           897:        
        !           898:        // 5 GENTLE PULSE 1
        !           899:        gi.configstring(CS_LIGHTS+5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj");
        !           900:        
        !           901:        // 6 FLICKER (second variety)
        !           902:        gi.configstring(CS_LIGHTS+6, "nmonqnmomnmomomno");
        !           903:        
        !           904:        // 7 CANDLE (second variety)
        !           905:        gi.configstring(CS_LIGHTS+7, "mmmaaaabcdefgmmmmaaaammmaamm");
        !           906:        
        !           907:        // 8 CANDLE (third variety)
        !           908:        gi.configstring(CS_LIGHTS+8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
        !           909:        
        !           910:        // 9 SLOW STROBE (fourth variety)
        !           911:        gi.configstring(CS_LIGHTS+9, "aaaaaaaazzzzzzzz");
        !           912:        
        !           913:        // 10 FLUORESCENT FLICKER
        !           914:        gi.configstring(CS_LIGHTS+10, "mmamammmmammamamaaamammma");
        !           915: 
        !           916:        // 11 SLOW PULSE NOT FADE TO BLACK
        !           917:        gi.configstring(CS_LIGHTS+11, "abcdefghijklmnopqrrqponmlkjihgfedcba");
        !           918:        
        !           919:        // styles 32-62 are assigned by the light program for switchable lights
        !           920: 
        !           921:        // 63 testing
        !           922:        gi.configstring(CS_LIGHTS+63, "a");
        !           923: }
        !           924: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.