| 3055 | |
| 3056 | |
| 3057 | cFluidSimulator * cWorld::InitializeFluidSimulator(cIniFile & a_IniFile, const char * a_FluidName, BLOCKTYPE a_SimulateBlock, BLOCKTYPE a_StationaryBlock) |
| 3058 | { |
| 3059 | AString SimulatorNameKey; |
| 3060 | Printf(SimulatorNameKey, "%sSimulator", a_FluidName); |
| 3061 | AString SimulatorSectionName; |
| 3062 | Printf(SimulatorSectionName, "%sSimulator", a_FluidName); |
| 3063 | AString SimulatorName = a_IniFile.GetValueSet("Physics", SimulatorNameKey, ""); |
| 3064 | if (SimulatorName.empty()) |
| 3065 | { |
| 3066 | LOGWARNING("[Physics] %s not present or empty in %s, using the default of \"Vanilla\".", SimulatorNameKey.c_str(), GetIniFileName().c_str()); |
| 3067 | SimulatorName = "Vanilla"; |
| 3068 | } |
| 3069 | |
| 3070 | cFluidSimulator * res = NULL; |
| 3071 | bool IsWater = (strcmp(a_FluidName, "Water") == 0); // Used for defaults |
| 3072 | int Rate = 1; |
| 3073 | if ( |
| 3074 | (NoCaseCompare(SimulatorName, "vaporize") == 0) || |
| 3075 | (NoCaseCompare(SimulatorName, "vaporise") == 0) |
| 3076 | ) |
| 3077 | { |
| 3078 | res = new cVaporizeFluidSimulator(*this, a_SimulateBlock, a_StationaryBlock); |
| 3079 | } |
| 3080 | else if ( |
| 3081 | (NoCaseCompare(SimulatorName, "noop") == 0) || |
| 3082 | (NoCaseCompare(SimulatorName, "nop") == 0) || |
| 3083 | (NoCaseCompare(SimulatorName, "null") == 0) || |
| 3084 | (NoCaseCompare(SimulatorName, "nil") == 0) |
| 3085 | ) |
| 3086 | { |
| 3087 | res = new cNoopFluidSimulator(*this, a_SimulateBlock, a_StationaryBlock); |
| 3088 | } |
| 3089 | else |
| 3090 | { |
| 3091 | int Falloff = a_IniFile.GetValueSetI(SimulatorSectionName, "Falloff", IsWater ? 1 : 2); |
| 3092 | int TickDelay = a_IniFile.GetValueSetI(SimulatorSectionName, "TickDelay", IsWater ? 5 : 30); |
| 3093 | int NumNeighborsForSource = a_IniFile.GetValueSetI(SimulatorSectionName, "NumNeighborsForSource", IsWater ? 2 : -1); |
| 3094 | |
| 3095 | if (NoCaseCompare(SimulatorName, "floody") == 0) |
| 3096 | { |
| 3097 | res = new cFloodyFluidSimulator(*this, a_SimulateBlock, a_StationaryBlock, Falloff, TickDelay, NumNeighborsForSource); |
| 3098 | } |
| 3099 | else if (NoCaseCompare(SimulatorName, "vanilla") == 0) |
| 3100 | { |
| 3101 | res = new cVanillaFluidSimulator(*this, a_SimulateBlock, a_StationaryBlock, Falloff, TickDelay, NumNeighborsForSource); |
| 3102 | } |
| 3103 | else |
| 3104 | { |
| 3105 | // The simulator name doesn't match anything we have, issue a warning: |
| 3106 | LOGWARNING("%s [Physics]:%s specifies an unknown simulator, using the default \"Vanilla\".", GetIniFileName().c_str(), SimulatorNameKey.c_str()); |
| 3107 | res = new cVanillaFluidSimulator(*this, a_SimulateBlock, a_StationaryBlock, Falloff, TickDelay, NumNeighborsForSource); |
| 3108 | } |
| 3109 | } |
| 3110 | |
| 3111 | m_SimulatorManager->RegisterSimulator(res, Rate); |
| 3112 | |
| 3113 | return res; |
| 3114 | } |
nothing calls this directly
no test coverage detected