void ParseSplash () { int splashnum; FSplashDef *splashdef; bool isnew = false; SC_MustGetString (); splashnum = (int)FindSplash (sc_String); if (splashnum < 0) { FSplashDef def; def.Name = copystring (sc_String); splashnum = (int)Splashes.Push (def); isnew = true; } splashdef = &Splashes[splashnum]; SC_MustGetString (); if (!SC_Compare ("modify") || (SC_MustGetString(), isnew)) { // Set defaults splashdef->SmallSplashSound = splashdef->NormalSplashSound = 0; splashdef->SmallSplash = splashdef->SplashBase = splashdef->SplashChunk = NULL; splashdef->ChunkXVelShift = splashdef->ChunkYVelShift = splashdef->ChunkZVelShift = 8; splashdef->ChunkBaseZVel = FRACUNIT; splashdef->SmallSplashClip = 12*FRACUNIT; splashdef->NoAlert = false; } if (!SC_Compare ("{")) { SC_ScriptError ("Expected {"); } else { GenericParse (SplashParser, SplashKeywords, splashdef, "splash", splashdef->Name); } }
void ParseSplash (FScanner &sc) { int splashnum; FSplashDef *splashdef; bool isnew = false; FName name; sc.MustGetString (); name = sc.String; splashnum = (int)FindSplash (name); if (splashnum < 0) { FSplashDef def; SetSplashDefaults (&def); def.Name = name; splashnum = (int)Splashes.Push (def); isnew = true; } splashdef = &Splashes[splashnum]; sc.MustGetString (); if (!sc.Compare ("modify")) { // Set defaults if (!isnew) { // New ones already have their defaults set before they're pushed. SetSplashDefaults (splashdef); } } else { sc.MustGetString(); } if (!sc.Compare ("{")) { sc.ScriptError ("Expected {"); } else { GenericParse (sc, SplashParser, SplashKeywords, splashdef, "splash", splashdef->Name); } }
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); }
static void GenericParse (FScanner &sc, FGenericParse *parser, const char **keywords, void *fields, const char *type, FName name) { bool notdone = true; int keyword; int val = 0; const PClass *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 (); SET_FIELD (FSoundID, FSoundID(sc.String)); /* unknown sounds never produce errors anywhere else so they shouldn't here either. if (val == 0) { Printf ("Unknown sound %s in %s %s\n", sc.String, type, name.GetChars()); } */ 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 = PClass::FindClass (sc.String); if (!info->IsDescendantOf (RUNTIME_CLASS(AActor))) { Printf ("%s is not an Actor (in %s %s)\n", sc.String, type, name.GetChars()); info = NULL; } else if (info == NULL) { Printf ("Unknown actor %s in %s %s\n", sc.String, type, name.GetChars()); } } SET_FIELD (const PClass *, 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.GetChars()); } break; case GEN_Float: sc.MustGetFloat (); SET_FIELD (float, 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 (sc, keyword, fields); break; } } while (notdone); }