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

unix.superglobalmegacorp.com

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