コード例 #1
0
ファイル: p_terrain.cpp プロジェクト: doomtech/zdoom-old
static void ParseDamage (int keyword, void *fields)
{
    FTerrainDef *def = (FTerrainDef *)fields;

    SC_MustGetString ();
    switch (SC_MustMatchString (DamageKeywords))
    {
    case DAM_Lava:
        def->DamageMOD = MOD_FIRE;
        break;

    case DAM_Ice:
        def->DamageMOD = MOD_ICE;
        break;

    case DAM_Slime:
        def->DamageMOD = MOD_SLIME;
        break;
    }
}
コード例 #2
0
ファイル: p_setup.c プロジェクト: Krazygamr/D-Touch
static void InitMapInfo(void)
{
    int map;
    int mapMax;
    int mcmdValue;
    mapInfo_t *info;
    char songMulch[10];

    mapMax = 1;

    // Put defaults into MapInfo[0]
    info = MapInfo;
    info->cluster = 0;
    info->warpTrans = 0;
    info->nextMap = 1;          // Always go to map 1 if not specified
    info->cdTrack = 1;
    info->sky1Texture = R_TextureNumForName(DEFAULT_SKY_NAME);
    info->sky2Texture = info->sky1Texture;
    info->sky1ScrollDelta = 0;
    info->sky2ScrollDelta = 0;
    info->doubleSky = false;
    info->lightning = false;
    info->fadetable = W_GetNumForName(DEFAULT_FADE_TABLE);
    strcpy(info->name, UNKNOWN_MAP_NAME);

//      strcpy(info->songLump, DEFAULT_SONG_LUMP);
    SC_Open(MAPINFO_SCRIPT_NAME);
    while (SC_GetString())
    {
        if (SC_Compare("MAP") == false)
        {
            SC_ScriptError(NULL);
        }
        SC_MustGetNumber();
        if (sc_Number < 1 || sc_Number > 99)
        {                       // 
            SC_ScriptError(NULL);
        }
        map = sc_Number;

        info = &MapInfo[map];

        // Save song lump name
        strcpy(songMulch, info->songLump);

        // Copy defaults to current map definition
        memcpy(info, &MapInfo[0], sizeof(*info));

        // Restore song lump name
        strcpy(info->songLump, songMulch);

        // The warp translation defaults to the map number
        info->warpTrans = map;

        // Map name must follow the number
        SC_MustGetString();
        strcpy(info->name, sc_String);

        // Process optional tokens
        while (SC_GetString())
        {
            if (SC_Compare("MAP"))
            {                   // Start next map definition
                SC_UnGet();
                break;
            }
            mcmdValue = MapCmdIDs[SC_MustMatchString(MapCmdNames)];
            switch (mcmdValue)
            {
                case MCMD_CLUSTER:
                    SC_MustGetNumber();
                    info->cluster = sc_Number;
                    break;
                case MCMD_WARPTRANS:
                    SC_MustGetNumber();
                    info->warpTrans = sc_Number;
                    break;
                case MCMD_NEXT:
                    SC_MustGetNumber();
                    info->nextMap = sc_Number;
                    break;
                case MCMD_CDTRACK:
                    SC_MustGetNumber();
                    info->cdTrack = sc_Number;
                    break;
                case MCMD_SKY1:
                    SC_MustGetString();
                    info->sky1Texture = R_TextureNumForName(sc_String);
                    SC_MustGetNumber();
                    info->sky1ScrollDelta = sc_Number << 8;
                    break;
                case MCMD_SKY2:
                    SC_MustGetString();
                    info->sky2Texture = R_TextureNumForName(sc_String);
                    SC_MustGetNumber();
                    info->sky2ScrollDelta = sc_Number << 8;
                    break;
                case MCMD_DOUBLESKY:
                    info->doubleSky = true;
                    break;
                case MCMD_LIGHTNING:
                    info->lightning = true;
                    break;
                case MCMD_FADETABLE:
                    SC_MustGetString();
                    info->fadetable = W_GetNumForName(sc_String);
                    break;
                case MCMD_CD_STARTTRACK:
                case MCMD_CD_END1TRACK:
                case MCMD_CD_END2TRACK:
                case MCMD_CD_END3TRACK:
                case MCMD_CD_INTERTRACK:
                case MCMD_CD_TITLETRACK:
                    SC_MustGetNumber();
                    cd_NonLevelTracks[mcmdValue - MCMD_CD_STARTTRACK] =
                        sc_Number;
                    break;
            }
        }
        mapMax = map > mapMax ? map : mapMax;
    }
    SC_Close();
    MapCount = mapMax;
}
コード例 #3
0
ファイル: c_level.cpp プロジェクト: JohnnyonFlame/odamex
static void ParseMapInfoLower (MapInfoHandler *handlers,
							   const char *strings[],
							   level_pwad_info_t *levelinfo,
							   cluster_info_t *clusterinfo,
							   DWORD flags)
{
	int entry;
	MapInfoHandler *handler;
	byte *info;

	info = levelinfo ? (byte *)levelinfo : (byte *)clusterinfo;

	while (SC_GetString ())
	{
		if (SC_MatchString (MapInfoTopLevel) != -1)
		{
			SC_UnGet ();
			break;
		}
		entry = SC_MustMatchString (strings);
		handler = handlers + entry;
		switch (handler->type)
		{
		case MITYPE_IGNORE:
			break;

		case MITYPE_EATNEXT:
			SC_MustGetString ();
			break;

		case MITYPE_INT:
			SC_MustGetNumber ();
			*((int *)(info + handler->data1)) = sc_Number;
			break;

		case MITYPE_FLOAT:
			SC_MustGetFloat ();
			*((float *)(info + handler->data1)) = sc_Float;
			break;

		case MITYPE_COLOR:
			{
				SC_MustGetString ();
				std::string string = V_GetColorStringByName (sc_String);
				if (string.length())
				{
					*((DWORD *)(info + handler->data1)) =
						V_GetColorFromString (NULL, string.c_str());
				}
				else
				{
					*((DWORD *)(info + handler->data1)) =
										V_GetColorFromString (NULL, sc_String);
				}
			}
			break;

		case MITYPE_MAPNAME:
			SC_MustGetString ();
			if (IsNum (sc_String))
			{
				int map = atoi (sc_String);
				sprintf (sc_String, "MAP%02d", map);
			}
			strncpy ((char *)(info + handler->data1), sc_String, 8);
			break;

		case MITYPE_LUMPNAME:
			SC_MustGetString ();
			uppercopy ((char *)(info + handler->data1), sc_String);
			break;

		case MITYPE_SKY:
			SC_MustGetString ();	// get texture name;
			uppercopy ((char *)(info + handler->data1), sc_String);
			SC_MustGetFloat ();		// get scroll speed
			//if (HexenHack)
			//{
			//	*((fixed_t *)(info + handler->data2)) = sc_Number << 8;
			//}
			//else
			//{
			//	*((fixed_t *)(info + handler->data2)) = (fixed_t)(sc_Float * 65536.0f);
			//}
			break;

		case MITYPE_SETFLAG:
			flags |= handler->data1;
			break;

		case MITYPE_SCFLAGS:
			flags = (flags & handler->data2) | handler->data1;
			break;

		case MITYPE_CLUSTER:
			SC_MustGetNumber ();
			*((int *)(info + handler->data1)) = sc_Number;
			if (HexenHack)
			{
				cluster_info_t *clusterH = FindClusterInfo (sc_Number);
				if (clusterH)
					clusterH->flags |= CLUSTER_HUB;
			}
			break;

		case MITYPE_STRING:
			SC_MustGetString ();
			ReplaceString ((const char **)(info + handler->data1), sc_String);
			break;

		case MITYPE_CSTRING:
			SC_MustGetString ();
			strncpy ((char *)(info + handler->data1), sc_String, handler->data2);
			*((char *)(info + handler->data1 + handler->data2)) = '\0';
			break;
		}
	}
	if (levelinfo)
		levelinfo->flags = flags;
	else
		clusterinfo->flags = flags;
}
コード例 #4
0
ファイル: c_level.cpp プロジェクト: JohnnyonFlame/odamex
//
// G_ParseMapInfo
// Parses the MAPINFO lumps of all loaded WADs and generates
// data for wadlevelinfos and wadclusterinfos.
//
void G_ParseMapInfo (void)
{
	int lump, lastlump = 0;
	level_pwad_info_t defaultinfo;
	level_pwad_info_t *levelinfo;
	int levelindex;
	cluster_info_t *clusterinfo;
	int clusterindex;
	DWORD levelflags;

	while ((lump = W_FindLump ("MAPINFO", &lastlump)) != -1)
	{
		SetLevelDefaults (&defaultinfo);
		SC_OpenLumpNum (lump, "MAPINFO");

		while (SC_GetString ())
		{
			switch (SC_MustMatchString (MapInfoTopLevel))
			{
			case MITL_DEFAULTMAP:
				SetLevelDefaults (&defaultinfo);
				ParseMapInfoLower (MapHandlers, MapInfoMapLevel, &defaultinfo, NULL, 0);
				break;

			case MITL_MAP:		// map <MAPNAME> <Nice Name>
				levelflags = defaultinfo.flags;
				SC_MustGetString ();
				if (IsNum (sc_String))
				{	// MAPNAME is a number, assume a Hexen wad
					int map = atoi (sc_String);
					sprintf (sc_String, "MAP%02d", map);
					SKYFLATNAME[5] = 0;
					HexenHack = true;
					// Hexen levels are automatically nointermission
					// and even lighting and no auto sound sequences
					levelflags |= LEVEL_NOINTERMISSION
								| LEVEL_EVENLIGHTING
								| LEVEL_SNDSEQTOTALCTRL;
				}
				levelindex = FindWadLevelInfo (sc_String);
				if (levelindex == -1)
				{
					levelindex = numwadlevelinfos++;
					wadlevelinfos = (level_pwad_info_t *)Realloc (wadlevelinfos, sizeof(level_pwad_info_t)*numwadlevelinfos);
				}
				levelinfo = wadlevelinfos + levelindex;
				memcpy (levelinfo, &defaultinfo, sizeof(*levelinfo));
				uppercopy (levelinfo->mapname, sc_String);
				SC_MustGetString ();
				ReplaceString (&levelinfo->level_name, sc_String);
				// Set up levelnum now so that the Teleport_NewMap specials
				// in hexen.wad work without modification.
				if (!strnicmp (levelinfo->mapname, "MAP", 3) && levelinfo->mapname[5] == 0)
				{
					int mapnum = atoi (levelinfo->mapname + 3);

					if (mapnum >= 1 && mapnum <= 99)
						levelinfo->levelnum = mapnum;
				}
				ParseMapInfoLower (MapHandlers, MapInfoMapLevel, levelinfo, NULL, levelflags);
				break;

			case MITL_CLUSTERDEF:	// clusterdef <clusternum>
				SC_MustGetNumber ();
				clusterindex = FindWadClusterInfo (sc_Number);
				if (clusterindex == -1)
				{
					clusterindex = numwadclusterinfos++;
					wadclusterinfos = (cluster_info_t *)Realloc (wadclusterinfos, sizeof(cluster_info_t)*numwadclusterinfos);
					memset (wadclusterinfos + clusterindex, 0, sizeof(cluster_info_t));
				}
				clusterinfo = wadclusterinfos + clusterindex;
				clusterinfo->cluster = sc_Number;
				ParseMapInfoLower (ClusterHandlers, MapInfoClusterLevel, NULL, clusterinfo, 0);
				break;
			}
		}
		SC_Close ();
	}
}
コード例 #5
0
ファイル: p_terrain.cpp プロジェクト: doomtech/zdoom-old
static void GenericParse (FGenericParse *parser, const char **keywords,
                          void *fields, const char *type, const char *name)
{
    bool notdone = true;
    int keyword;
    int val;
    const TypeInfo *info;

    do
    {
        SC_MustGetString ();
        keyword = SC_MustMatchString (keywords);
        switch (parser[keyword].Type)
        {
        case GEN_End:
            notdone = false;
            break;

        case GEN_Fixed:
            SC_MustGetFloat ();
            SET_FIELD (fixed_t, (fixed_t)(FRACUNIT * sc_Float));
            break;

        case GEN_Sound:
            SC_MustGetString ();
            val = S_FindSound (sc_String);
            SET_FIELD (int, val);
            if (val == 0)
            {
                Printf ("Unknown sound %s in %s %s\n",
                        sc_String, type, name);
            }
            break;

        case GEN_Byte:
            SC_MustGetNumber ();
            SET_FIELD (byte, sc_Number);
            break;

        case GEN_Class:
            SC_MustGetString ();
            if (SC_Compare ("None"))
            {
                info = NULL;
            }
            else
            {
                info = TypeInfo::IFindType (sc_String);
                if (!info->IsDescendantOf (RUNTIME_CLASS(AActor)))
                {
                    Printf ("%s is not an Actor (in %s %s)\n",
                            sc_String, type, name);
                    info = NULL;
                }
                else if (info == NULL)
                {
                    Printf ("Unknown actor %s in %s %s\n",
                            sc_String, type, name);
                }
            }
            SET_FIELD (const TypeInfo *, info);
            break;

        case GEN_Splash:
            SC_MustGetString ();
            val = FindSplash (sc_String);
            SET_FIELD (int, val);
            if (val == -1)
            {
                Printf ("Splash %s is not defined yet (in %s %s)\n",
                        sc_String, type, name);
            }
            break;

        case GEN_Float:
            SC_MustGetFloat ();
            SET_FIELD (float, sc_Float);
            break;

        case GEN_Time:
            SC_MustGetFloat ();
            SET_FIELD (int, (int)(sc_Float * TICRATE));
            break;

        case GEN_Bool:
            SET_FIELD (bool, true);
            break;

        case GEN_Int:
            SC_MustGetNumber ();
            SET_FIELD (int, sc_Number);
            break;

        case GEN_Custom:
            parser[keyword].u.Handler (keyword, fields);
            break;
        }
    } while (notdone);
}
コード例 #6
0
ファイル: p_terrain.cpp プロジェクト: doomtech/zdoom-old
static void ParseOuter ()
{
    int bracedepth = 0;
    bool ifskip = false;

    while (SC_GetString ())
    {
        if (ifskip)
        {
            if (bracedepth > 0)
            {
                if (SC_Compare ("}"))
                {
                    bracedepth--;
                    continue;
                }
            }
            else if (SC_Compare ("endif"))
            {
                ifskip = false;
                continue;
            }
            if (SC_Compare ("{"))
            {
                bracedepth++;
            }
            else if (SC_Compare ("}"))
            {
                SC_ScriptError ("Too many left braces ('}')");
            }
        }
        else
        {
            switch (SC_MustMatchString (OuterKeywords))
            {
            case OUT_SPLASH:
                ParseSplash ();
                break;

            case OUT_TERRAIN:
                ParseTerrain ();
                break;

            case OUT_FLOOR:
                ParseFloor ();
                break;

            case OUT_IFDOOM:
                if (gameinfo.gametype != GAME_Doom)
                {
                    ifskip = true;
                }
                break;

            case OUT_IFHERETIC:
                if (gameinfo.gametype != GAME_Heretic)
                {
                    ifskip = true;
                }
                break;

            case OUT_IFHEXEN:
                if (gameinfo.gametype != GAME_Hexen)
                {
                    ifskip = true;
                }
                break;

            case OUT_IFSTRIFE:
                if (gameinfo.gametype != GAME_Strife)
                {
                    ifskip = true;
                }
                break;

            case OUT_ENDIF:
                break;
            }
        }
    }
}