void ParseTextMap(MapData *map) { char *buffer = new char[map->Size(ML_TEXTMAP)]; isTranslated = true; isExtended = false; floordrop = false; map->Read(ML_TEXTMAP, buffer); sc.OpenMem(Wads.GetLumpFullName(map->lumpnum), buffer, map->Size(ML_TEXTMAP)); delete [] buffer; sc.SetCMode(true); if (sc.CheckString("namespace")) { sc.MustGetStringName("="); sc.MustGetString(); namespc = sc.String; switch(namespc) { case NAME_ZDoom: namespace_bits = Zd; isTranslated = false; break; case NAME_ZDoomTranslated: level.flags2 |= LEVEL2_DUMMYSWITCHES; namespace_bits = Zdt; break; case NAME_Vavoom: namespace_bits = Va; isTranslated = false; break; case NAME_Hexen: namespace_bits = Hx; isTranslated = false; break; case NAME_Doom: namespace_bits = Dm; P_LoadTranslator("xlat/doom_base.txt"); level.flags2 |= LEVEL2_DUMMYSWITCHES; floordrop = true; break; case NAME_Heretic: namespace_bits = Ht; P_LoadTranslator("xlat/heretic_base.txt"); level.flags2 |= LEVEL2_DUMMYSWITCHES; floordrop = true; break; case NAME_Strife: namespace_bits = St; P_LoadTranslator("xlat/strife_base.txt"); level.flags2 |= LEVEL2_DUMMYSWITCHES|LEVEL2_RAILINGHACK; floordrop = true; break; default: Printf("Unknown namespace %s. Using defaults for %s\n", sc.String, GameTypeName()); switch (gameinfo.gametype) { default: // Shh, GCC case GAME_Doom: case GAME_Chex: namespace_bits = Dm; P_LoadTranslator("xlat/doom_base.txt"); break; case GAME_Heretic: namespace_bits = Ht; P_LoadTranslator("xlat/heretic_base.txt"); break; case GAME_Strife: namespace_bits = St; P_LoadTranslator("xlat/strife_base.txt"); break; case GAME_Hexen: namespace_bits = Hx; isTranslated = false; break; } } sc.MustGetStringName(";"); } else { Printf("Map does not define a namespace.\n"); } while (sc.GetString()) { if (sc.Compare("thing")) { FMapThing th; unsigned userdatastart = MapThingsUserData.Size(); ParseThing(&th); MapThingsConverted.Push(th); if (userdatastart < MapThingsUserData.Size()) { // User data added MapThingsUserDataIndex[MapThingsConverted.Size()-1] = userdatastart; // Mark end of the user data for this map thing FMapThingUserData ud; ud.Property = NAME_None; ud.Value = 0; MapThingsUserData.Push(ud); } } else if (sc.Compare("linedef")) { line_t li; ParseLinedef(&li, ParsedLines.Size()); ParsedLines.Push(li); } else if (sc.Compare("sidedef")) { side_t si; intmapsidedef_t st; ParseSidedef(&si, &st, ParsedSides.Size()); ParsedSides.Push(si); ParsedSideTextures.Push(st); } else if (sc.Compare("sector")) { sector_t sec; ParseSector(&sec, ParsedSectors.Size()); ParsedSectors.Push(sec); } else if (sc.Compare("vertex")) { vertex_t vt; vertexdata_t vd; ParseVertex(&vt, &vd); ParsedVertices.Push(vt); ParsedVertexDatas.Push(vd); } else { Skip(); } } // Catch bogus maps here rather than during nodebuilding if (ParsedVertices.Size() == 0) I_Error("Map has no vertices.\n"); if (ParsedSectors.Size() == 0) I_Error("Map has no sectors. \n"); if (ParsedLines.Size() == 0) I_Error("Map has no linedefs.\n"); if (ParsedSides.Size() == 0) I_Error("Map has no sidedefs.\n"); // Create the real vertices numvertexes = ParsedVertices.Size(); vertexes = new vertex_t[numvertexes]; memcpy(vertexes, &ParsedVertices[0], numvertexes * sizeof(*vertexes)); // Create the real vertex datas numvertexdatas = ParsedVertexDatas.Size(); vertexdatas = new vertexdata_t[numvertexdatas]; memcpy(vertexdatas, &ParsedVertexDatas[0], numvertexdatas * sizeof(*vertexdatas)); // Create the real sectors numsectors = ParsedSectors.Size(); sectors = new sector_t[numsectors]; memcpy(sectors, &ParsedSectors[0], numsectors * sizeof(*sectors)); sectors[0].e = new extsector_t[numsectors]; for(int i = 0; i < numsectors; i++) { sectors[i].e = §ors[0].e[i]; } // Create the real linedefs and decompress the sidedefs ProcessLineDefs(); }
void FStringTable::LoadLanguage (int lumpnum, DWORD code, bool exactMatch, int passnum) { static bool errordone = false; const DWORD orMask = exactMatch ? 0 : MAKE_ID(0,0,0xff,0); DWORD inCode = 0; StringEntry *entry, **pentry; DWORD bucket; int cmpval; bool skip = true; code |= orMask; FScanner sc(lumpnum); sc.SetCMode (true); while (sc.GetString ()) { if (sc.Compare ("[")) { // Process language identifiers bool donot = false; bool forceskip = false; skip = true; sc.MustGetString (); do { size_t len = sc.StringLen; if (len != 2 && len != 3) { if (len == 1 && sc.String[0] == '~') { donot = true; sc.MustGetString (); continue; } if (len == 1 && sc.String[0] == '*') { inCode = MAKE_ID('*',0,0,0); } else if (len == 7 && stricmp (sc.String, "default") == 0) { inCode = MAKE_ID('*','*',0,0); } else { sc.ScriptError ("The language code must be 2 or 3 characters long.\n'%s' is %lu characters long.", sc.String, len); } } else { inCode = MAKE_ID(tolower(sc.String[0]), tolower(sc.String[1]), tolower(sc.String[2]), 0); } if ((inCode | orMask) == code) { if (donot) { forceskip = true; donot = false; } else { skip = false; } } sc.MustGetString (); } while (!sc.Compare ("]")); if (donot) { sc.ScriptError ("You must specify a language after ~"); } skip |= forceskip; } else { // Process string definitions. if (inCode == 0) { // LANGUAGE lump is bad. We need to check if this is an old binary // lump and if so just skip it to allow old WADs to run which contain // such a lump. if (!sc.isText()) { if (!errordone) Printf("Skipping binary 'LANGUAGE' lump.\n"); errordone = true; return; } sc.ScriptError ("Found a string without a language specified."); } bool savedskip = skip; if (sc.Compare("$")) { sc.MustGetStringName("ifgame"); sc.MustGetStringName("("); sc.MustGetString(); skip |= !sc.Compare(GameTypeName()); sc.MustGetStringName(")"); sc.MustGetString(); } if (skip) { // We're not interested in this language, so skip the string. sc.MustGetStringName ("="); sc.MustGetString (); do { sc.MustGetString (); } while (!sc.Compare (";")); skip = savedskip; continue; } FString strName (sc.String); sc.MustGetStringName ("="); sc.MustGetString (); FString strText (sc.String, ProcessEscapes (sc.String)); sc.MustGetString (); while (!sc.Compare (";")) { ProcessEscapes (sc.String); strText += sc.String; sc.MustGetString (); } // Does this string exist? If so, should we overwrite it? bucket = MakeKey (strName.GetChars()) & (HASH_SIZE-1); pentry = &Buckets[bucket]; entry = *pentry; cmpval = 1; while (entry != NULL) { cmpval = stricmp (entry->Name, strName.GetChars()); if (cmpval >= 0) break; pentry = &entry->Next; entry = *pentry; } if (cmpval == 0 && entry->PassNum >= passnum) { *pentry = entry->Next; M_Free (entry); entry = NULL; } if (entry == NULL || cmpval > 0) { entry = (StringEntry *)M_Malloc (sizeof(*entry) + strText.Len() + strName.Len() + 2); entry->Next = *pentry; *pentry = entry; strcpy (entry->String, strText.GetChars()); strcpy (entry->Name = entry->String + strText.Len() + 1, strName.GetChars()); entry->PassNum = passnum; } } } }