Move some files around.

This commit is contained in:
Mari the Deer 2022-12-15 17:15:42 +01:00
commit fef9d69f46
4 changed files with 6 additions and 7 deletions

View file

@ -0,0 +1,344 @@
// Handler responsible for item replacements and whatever else
// most of the code is split up to make it easier to navigate
Class SWWMHandler : EventHandler
{
transient int lastlock;
transient int lastpickuptic[MAXPLAYERS]; // these two are mostly used
transient int lastnuggettic[MAXPLAYERS]; // to avoid deafening players
SWWMScoreObj scorenums;
SWWMDamNum damnums;
SWWMInterest intpoints;
Array<String> damtypes, damcolors;
transient CVar usedamcolors;
transient int slotstrictwarn;
transient ui String sswstr;
transient ui BrokenLines sswl;
// stuff to reduce worldthingspawned overhead
int bossmap;
int iwantdie;
int indoomvacation;
int inultdoom2;
Array<Service> funtagsv, mergemonstersv;
// for checkreplacement
bool hasdrlamonsters, haslegionofbones;
int iskdizd;
Array<String> bludtypes;
// mod inter-compat stuff
bool ccloaded;
// session globals
SWWMGlobals gdat;
// profiling data
bool profiling;
int bprofiletics, profiletics; // how many tics to aggregate data for
double prof_ms[8], prof_avg[8];
int prof_calls[8];
double curms;
// to avoid some overlaps
ui DSMapTitle mapmsg;
// corruption cards stuff
ui bool incardmenu, cardmessaged;
enum EProfileTimer
{
PT_WORLDTICK,
PT_WORLDTHINGSPAWNED,
PT_WORLDTHINGDESTROYED,
PT_WORLDTHINGDIED,
PT_WORLDTHINGDAMAGED,
PT_WORLDTHINGREVIVED,
PT_CHECKREPLACEMENT,
PT_CHECKREPLACEE
}
private void ProfileTick()
{
curms = MSTimeF();
}
private void ProfileTock( int idx )
{
double diff = (MSTimeF()-curms);
prof_ms[idx] += diff;
prof_avg[idx] = (prof_calls[idx]>0)?(prof_avg[idx]+diff)/2.:diff;
prof_calls[idx]++;
}
override void OnRegister()
{
// oneliner RNG must be relative to consoleplayer
SetRandomSeed[DemoLines](Random[DemoLines]()+consoleplayer+MSTime());
// "uninitialize" some vars
iwantdie = -1;
bossmap = -1;
indoomvacation = -1;
inultdoom2 = -1;
// class-checking ones can be initialized here easily
foreach ( cls:AllActorClasses )
{
if ( cls.GetClassName() == "RLMonster" ) hasdrlamonsters = true;
else if ( cls.GetClassName() == "LOBZombieman" ) haslegionofbones = true;
}
foreach ( cls:AllClasses )
{
if ( cls.GetClassName() != "CCards_Global" ) continue;
ccloaded = true;
break;
}
if ( LevelInfo.MapExists("Z1M1") && (LevelInfo.MapChecksum("Z1M1") ~== "2B7744234ED2C162AD08A3255E979F65") )
iskdizd = true;
// read bludtype files if they can be found
for ( int lmp = Wads.FindLump("BLUDTYPE"); lmp != -1; lmp = Wads.FindLump("BLUDTYPE",lmp+1) )
{
String dat = Wads.ReadLump(lmp);
Array<String> list;
// fucking Windows
dat.Replace("\r","");
list.Clear();
dat.Split(list,"\n");
foreach ( l:list )
{
if ( (l.Length() == 0) || (l.Left(2) == "//") || (l.Left(1) == "") )
continue;
bludtypes.Push(l);
}
}
// read damnum colors
damtypes.Clear();
damcolors.Clear();
for ( int lmp = Wads.FindLump("DAMTYPES"); lmp != -1; lmp = Wads.FindLump("DAMTYPES",lmp+1) )
{
String dat = Wads.ReadLump(lmp);
Array<String> list;
// fucking Windows
dat.Replace("\r","");
list.Clear();
dat.Split(list,"\n");
foreach ( l:list )
{
if ( (l.Length() == 0) || (l.Left(1) == "#") || (l.Left(1) == "") )
continue;
int spc = l.IndexOf(" ");
damtypes.Push(l.Left(spc));
damcolors.Push(l.Mid(spc+1));
}
}
// cache various services into the handler on register
// this dramatically reduces overhead by not having to use an iterator every time they're needed
// especially noticeable for fun tags, as they're looked up for every monster on map load
let si = ServiceIterator.Find("FunTagService");
Service sv;
while ( sv = si.Next() ) funtagsv.Push(sv);
si = ServiceIterator.Find("MergeMonsterService");
while ( sv = si.Next() ) mergemonstersv.Push(sv);
// session globals
gdat = SWWMGlobals.Get();
// start profiling
if ( swwm_profstart <= 0 ) return;
bprofiletics = profiletics = swwm_profstart;
profiling = true;
for ( int i=0; i<8; i++ )
{
prof_ms[i] = 0;
prof_avg[i] = 0;
prof_calls[i] = 0;
}
Console.Printf("Gathering data for %d tic%s...",bprofiletics,(bprofiletics>1)?"s":"");
}
override void WorldTick()
{
if ( profiling ) ProfileTick();
LangRefresh();
QueueMaintenance();
if ( !mnotify && (level.maptime >= 5) )
{
mnotify = true;
let ti = ThinkerIterator.Create("SWWMStats",Thinker.STAT_STATIC);
SWWMStats s;
while ( s = SWWMStats(ti.Next()) )
{
if ( !SWWMUtility.IsKnownMap() ) break;
if ( s.myplayer != players[consoleplayer] ) continue;
int clust = level.cluster;
if ( SWWMUtility.IsEviternity() )
{
// we have to do some heavy lifting here because episodes don't match clusters
if ( level.levelnum <= 5 ) clust = 1;
else if ( level.levelnum <= 10 ) clust = 2;
else if ( level.levelnum <= 15 ) clust = 3;
else if ( level.levelnum <= 20 ) clust = 4;
else if ( level.levelnum <= 25 ) clust = 5;
else if ( level.levelnum <= 30 ) clust = 6;
else if ( level.levelnum <= 31 ) clust = 7;
else if ( level.levelnum <= 32 ) clust = 8;
}
int csiz = s.clustervisit.Size();
if ( (csiz > 0) && (s.clustervisit[csiz-1] != clust) )
Console.Printf(StringTable.Localize("$SWWM_NEWMISSION"));
}
}
for ( int i=0; i<legtrack.Size(); i++ )
{
// when a monster mutates, update its healthbar for all players
for ( int j=0; j<MAXPLAYERS; j++ )
{
if ( !playeringame[j] ) continue;
let t = SWWMQuickCombatTracker.Update(self,players[j],legtrack[i].Owner);
if ( t && (t.myplayer == players[consoleplayer]) ) Console.Printf(StringTable.Localize("$SWWM_LTFORM"),t.mytag);
}
legtrack.Delete(i--);
}
// healthbar on whatever the player is aiming at
for ( int i=0; i<MAXPLAYERS; i++ )
{
if ( !playeringame[i] || (players[i].Health <= 0) || !players[i].mo ) continue;
let t = players[i].mo.GetPointer(AAPTR_PLAYER_GETTARGET);
if ( t && t.bSHOOTABLE && (t.Health > 0) ) SWWMQuickCombatTracker.Update(self,players[i],t);
// keep healthbars updated for all friends of this player
for ( int j=0; j<MAXPLAYERS; j++ )
{
if ( !playeringame[j] || (players[j].Health <= 0) || !players[j].mo || !players[j].mo.IsFriend(players[i].mo) ) continue;
SWWMQuickCombatTracker.Update(self,players[j],players[i].mo);
}
}
OnelinerTick();
FlashTick();
ItemCountTrack();
CombatTrack();
OneHundredPercentCheck();
UpdateHUDObjects();
SimpleTracking();
VanillaBossTick();
if ( !profiling ) return;
ProfileTock(PT_WorldTick);
Console.Printf("%d...",profiletics);
profiletics--;
if ( profiletics > 0 ) return;
profiling = false;
static const String prof_name[] =
{
"WorldTick ",
"WorldThingSpawned ",
"WorldThingDestroyed",
"WorldThingDied ",
"WorldThingDamaged ",
"WorldThingRevived ",
"CheckReplacement ",
"CheckReplacee "
};
Console.Printf("Done!");
String str = String.Format(
"SWWMHandler profiling info for %d tic%s:\n"
" event name | calls | total ms | avg ms\n"
"---------------------|--------|-------------|-------------\n",
bprofiletics,(bprofiletics>1)?"s":"");
for ( int i=0; i<8; i++ )
str.AppendFormat(" %s | %6d | %11.6f | %11.6f\n",prof_name[i],prof_calls[i],prof_ms[i],prof_avg[i]);
Console.Printf(str);
}
override void PostUiTick()
{
OnelinerUITick();
FlashUITick();
VanillaBossUITick();
// corruption cards dialogue
if ( ccloaded && !gdat.ccstartonce && !cardmessaged && (gamestate == GS_LEVEL) )
{
let m = Menu.GetCurrentMenu();
if ( m && (m.GetClassName() == 'CorruptionCardsSelector') ) incardmenu = true;
else if ( incardmenu )
{
if ( !swwm_ccmessage ) SWWMDialogues.StartSeq(SWWMDLG_CC);
CVar.GetCVar('swwm_ccmessage').SetBool(true);
cardmessaged = true;
SendNetworkEvent("swwmccstart");
}
}
}
override void WorldLinePreActivated( WorldEvent e )
{
// oneliner on locked doors
if ( !e.Thing ) return;
int locknum = SWWMUtility.GetLineLock(e.ActivatedLine);
if ( (locknum < 1) || (locknum > 255) ) return;
if ( e.Thing.CheckLocalView() && !e.Thing.CheckKeys(locknum,false,true) )
{
if ( !lastlock || (gametic > lastlock+20) )
{
if ( SWWMUtility.IsValidLockNum(locknum) )
lastlock = AddOneliner("locked",2);
else lastlock = AddOneliner("jammed",2);
}
}
}
override void WorldLineActivated( WorldEvent e )
{
if ( !(e.ActivationType&SPAC_Use) ) return;
if ( !e.Thing || !e.Thing.player ) return;
if ( (e.Thing.player == players[consoleplayer]) && swwm_beepboop )
SWWMHandler.AddOneliner("buttonpush",2,0);
let w = SWWMWeapon(e.Thing.player.ReadyWeapon);
if ( (!w || !w.wallponch) && (!(e.Thing is 'Demolitionist') || !Demolitionist(e.Thing).hitactivate) ) return;
let s = SWWMStats.Find(e.Thing.player);
if ( s ) s.wponch++;
SWWMUtility.AchievementProgressInc("slemg",1,e.Thing.player);
}
// stuff for hud
override void RenderUnderlay( RenderEvent e )
{
// armor/health flashes
FlashRender(e);
if ( slotstrictwarn && (gametic < slotstrictwarn) )
{
String str = StringTable.Localize("$SWWM_SETSLOTSTRICT");
if ( sswstr != str )
{
sswstr = str;
if ( sswl ) sswl.Destroy();
}
double t = (slotstrictwarn-(gametic+e.FracTic))/20.;
double alph = clamp(t,0.,1.);
if ( !sswl ) sswl = newsmallfont.BreakLines(sswstr,300);
double yy = (200-sswl.Count()*newsmallfont.GetHeight())/2;
for ( int i=0; i<sswl.Count(); i++ )
{
double xx = (320-sswl.StringWidth(i))/2;
Screen.DrawText(newsmallfont,Font.CR_UNTRANSLATED,xx,yy,sswl.StringAt(i),DTA_Clean,true,DTA_Alpha,alph);
yy += newsmallfont.GetHeight();
}
sswl.Destroy();
}
// weapon underlays
let sw = SWWMWeapon(players[consoleplayer].ReadyWeapon);
if ( sw )
{
sw.RenderUnderlay(e);
if ( sw.bHASSCRTEX ) sw.RenderTexture(e);
}
TraceCrosshairs(e);
RenderCrosshairs(e);
if ( !statusbar || !(statusbar is 'SWWMStatusBar') ) return;
SWWMStatusBar(statusbar).viewpos = e.viewpos;
SWWMStatusBar(statusbar).viewrot = (e.viewangle,e.viewpitch,e.viewroll);
}
// various shaders
override void RenderOverlay( RenderEvent e )
{
CheatOverlay(e);
RenderShaders(e);
DrawDebug(e);
}
}

View file

@ -0,0 +1,538 @@
// Static handler responsible for some special stuff
// save version holder
Class SWWMSaveVerData : SWWMStaticThinker
{
String ver;
int uid;
}
Class SWWMStaticHandler : StaticEventHandler
{
// crash handler
ui bool wasinmap;
ui int timer, msgpick;
// versioning
bool tainted;
String taintver;
int uid;
int checktic;
int maptime;
bool unloading;
ui Dictionary menustate; // used by Demolitionist Menu to restore old menu positions
// title stuff
ui bool titlefirst;
// map title stuff
int mttics;
// warnings
bool mpwarned;
// checks
ThinkerIterator sti;
// for intermissions, to prevent repetition
ui Array<int> lasttip, lastart;
// stupid dumb thing
ui bool aprilfools;
ui Font aprfnt;
override void NewGame()
{
// set save version every new session
let svd = new("SWWMSaveVerData");
svd.ChangeStatNum(Thinker.STAT_STATIC);
svd.ver = StringTable.Localize("$SWWM_SHORTVER");
uid = 0;
}
override void WorldUnloaded( WorldEvent e )
{
SWWMHandler.ClearAllShaders();
unloading = true;
}
override void WorldTick()
{
if ( mttics > 0 )
{
mttics--;
if ( mttics == 0 ) EventHandler.SendInterfaceEvent(consoleplayer,"swwmmaptitle");
}
maptime++;
// in case we start late?
if ( multiplayer && !mpwarned )
{
mpwarned = true;
Console.Printf("\cgWARNING:\c- Multiplayer is no longer officially supported, desyncs and other issues may potentially happen. You are on your own.");
S_StartSound("compat/warn",CHAN_YOUDONEFUCKEDUP,CHANF_UI|CHANF_NOPAUSE|CHANF_OVERLAP,1,ATTN_NONE);
}
// sanity check
Array<Thinker> stinkers;
if ( !sti ) sti = ThinkerIterator.Create("SWWMStaticThinker");
else sti.Reinit();
Thinker t;
while ( t = sti.Next() ) stinkers.Push(t);
if ( stinkers.Size() > 0 )
{
foreach ( s:stinkers ) Console.Printf("%s is not STAT_STATIC!",s.GetClassName());
ThrowAbortException("Panic! %d static thinker%s been tampered with!",stinkers.Size(),(stinkers.Size()==1)?" has":"s have");
}
}
override void WorldLoaded( WorldEvent e )
{
if ( gamestate != GS_TITLELEVEL )
mttics = 10; // count down to show the "area name"
unloading = false;
maptime = 0;
if ( e.IsSavegame || e.IsReopen )
{
// restore underwater sounds for players
for ( int i=0; i<MAXPLAYERS; i++ )
{
if ( !playeringame[i] || !(players[i].mo is 'Demolitionist') ) continue;
Demolitionist(players[i].mo).CheckUnderwaterAmb(true);
}
}
SWWMHandler.ClearAllShaders();
EventHandler.SendInterfaceEvent(consoleplayer,"swwmflushhud");
// force a reset of the minimap zoom in case it's set beyond safe levels
double mmz = swwm_mm_zoom;
if ( level.allmap && (mmz >= 2.) ) mmz = 2.;
else if ( mmz >= 1. ) mmz = 1.;
else mmz = .5;
CVar.FindCVar('swwm_mm_zoom').SetFloat(mmz);
EventHandler.SendInterfaceEvent(consoleplayer,"swwmaprcheck");
if ( !e.IsSaveGame ) return;
// save version checker
tainted = false;
taintver = "";
checktic = gametic+5;
let ti = ThinkerIterator.Create("SWWMSaveVerData",Thinker.STAT_STATIC);
let svd = SWWMSaveVerData(ti.Next());
if ( !svd )
{
tainted = true;
taintver = "\cg(no version info)\c-";
uid = 0;
}
else
{
String cver = StringTable.Localize("$SWWM_SHORTVER");
if ( svd.ver != cver )
{
tainted = true;
taintver = svd.ver;
}
if ( svd.uid == uid ) checktic = 0;
uid = svd.uid;
}
}
override void OnUnregister()
{
// save achievements on exit
SaveAchievements();
}
override void OnRegister()
{
// fix voice type cvar
int lmp;
Array<String> types;
for ( lmp = Wads.FindLumpFullName("swwmvoicepack.txt"); lmp != -1; lmp = Wads.FindLumpFullName("swwmvoicepack.txt",lmp+1) )
{
Array<String> lst;
lst.Clear();
String dat = Wads.ReadLump(lmp);
dat.Split(lst,"\n",0);
foreach ( l:lst )
{
if ( (l.Length() <= 0) || (l.GetNextCodePoint(0) == 0) || (l.Left(1) == "\n") || (l.Left(1) == "#") ) continue;
types.Push(l);
}
}
let cv = CVar.FindCVar('swwm_voicetype');
if ( types.Find(cv.GetString()) >= types.Size() )
cv.SetString("default");
// load up the achievements
if ( swwm_achievementstate == "" ) MigrateAchievements();
else LoadAchievements();
// precache fonts
Array<String> fonts;
for ( lmp = Wads.FindLumpFullName("precachefonts.txt"); lmp != -1; lmp = Wads.FindLumpFullName("precachefonts.txt",lmp+1) )
{
Array<String> lst;
lst.Clear();
String dat = Wads.ReadLump(lmp);
dat.Split(lst,"\n",0);
foreach ( l:lst )
{
if ( (l.Length() <= 0) || (l.GetNextCodePoint(0) == 0) || (l.Left(1) == "\n") || (l.Left(1) == "#") ) continue;
fonts.Push(l);
}
}
foreach ( f:fonts ) Font.GetFont(f);
// warn: mp no longer officially maintained
if ( multiplayer )
{
mpwarned = true;
Console.Printf("\cgWARNING:\c- Multiplayer is no longer officially supported, desyncs and other issues may potentially happen. You are on your own.");
S_StartSound("compat/warn",CHAN_YOUDONEFUCKEDUP,CHANF_UI|CHANF_NOPAUSE|CHANF_OVERLAP,1,ATTN_NONE);
}
// warning for unsupported
if ( Wads.FindLumpFullName("swwmgamesupported.txt") != -1 ) return;
Console.Printf(
"\cx┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\c-\n"
"\cx┃ \cr[\cgWARNING\cr] \cx┃\c-\n"
"\cx┃ \chSWWM \czGZ \cjis \cfNOT\cj compatible with the loaded IWAD. \cx┃\c-\n"
"\cx┃ \cjOnly \cfDoom\cj, \cfHeretic\cj and \cfHexen\cj are supported. \cx┃\c-\n"
"\cx┃ \cjIssues \cfCAN\cj and \cfWILL\cj happen. \cx┃\c-\n"
"\cx┃ \cr[\cgYOU ARE ON YOUR OWN\cr] \cx┃\c-\n"
"\cx┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\c-");
S_StartSound("compat/warn",CHAN_YOUDONEFUCKEDUP,CHANF_UI|CHANF_NOPAUSE|CHANF_OVERLAP,1,ATTN_NONE);
}
override void RenderOverlay( RenderEvent e )
{
// silly april fools thing
if ( aprilfools && (gamestate == GS_LEVEL) )
{
String str = "Unregistered Ultracam";
if ( !aprfnt ) aprfnt = Font.GetFont("TewiFontOutline");
Screen.DrawText(aprfnt,Font.CR_WHITE,(Screen.GetWidth()-aprfnt.StringWidth(str)*CleanXFac_1)/2,2*CleanYFac_1,str,DTA_CleanNoMove_1,true);
}
}
override void InterfaceProcess( ConsoleEvent e )
{
if ( e.IsManual ) return;
if ( e.Name ~== "swwmmaptitle" )
{
if ( (gamestate != GS_LEVEL) || !swwm_showmaptitle ) return;
StatusBar.AttachMessage(new("DSMapTitle").Init(),-7777);
}
else if ( e.Name ~== "swwmflushud" )
{
if ( !(StatusBar is 'SWWMStatusBar') ) return;
SWWMStatusBar(StatusBar).Flush();
}
else if ( e.Name ~== "swwmaprcheck" )
{
if ( gamestate != GS_LEVEL ) return;
if ( SystemTime.Format("%d%m",SystemTime.Now()) == "0104" )
{
if ( !aprilfools ) SWWMDialogues.StartSeq(SWWMDLG_FOOL);
aprilfools = true;
}
else aprilfools = false;
}
}
override void ConsoleProcess( ConsoleEvent e )
{
if ( e.Name ~== "swwmresetmmcolors" )
{
Array<String> cvarlist;
SWWMUtility.GetCVars(cvarlist);
foreach ( cv:cvarlist )
{
if ( (cv.Left(8) != "swwm_mm_")
|| (cv.IndexOf("color") == -1)
|| (cv == "swwm_mm_colorset") )
continue;
CVar.FindCVar(cv).ResetToDefault();
}
}
else if ( e.Name ~== "swwmresetcvars" )
{
Array<String> cvarlist;
SWWMUtility.GetCVars(cvarlist);
foreach ( cv:cvarlist )
{
// don't reset these
if ( (cv == "swwm_playtime")
|| (cv == "swwm_achievementstate")
|| (cv == "swwm_achievementprogress") )
continue;
CVar.FindCVar(cv).ResetToDefault();
}
}
else if ( e.Name ~== "swwmresettooltips" )
{
CVar.FindCVar('swwm_tooltipshown').ResetToDefault();
CVar.FindCVar('swwm_tooltipnote').ResetToDefault();
}
else if ( e.Name ~== "swwmlistcvars" )
{
// debug
Array<String> cvarlist;
SWWMUtility.GetCVars(cvarlist);
foreach ( cv:cvarlist )
{
let rcv = CVar.FindCVar(cv);
Console.Printf(cv.." = "..rcv.GetString());
}
}
else if ( e.Name ~== "swwmgetplaytime" )
{
int val = swwm_playtime;
int sec = (val%60);
int min = ((val/60)%60);
int hour = ((val/3600)%24);
int day = val/86400;
String str = "";
if ( day ) str.AppendFormat("%d days",day);
if ( hour )
{
if ( str != "" ) str = str..", ";
str.AppendFormat("%d hours",hour);
}
if ( min )
{
if ( str != "" ) str = str..", ";
str.AppendFormat("%d minutes",min);
}
if ( sec )
{
if ( str != "" ) str = str..", ";
str.AppendFormat("%d seconds",sec);
}
if ( str == "" ) Console.Printf("No Data");
else Console.Printf(str);
}
else if ( e.Name ~== "swwmresetachievements" )
{
foreach ( inf:achievementinfo )
{
achievementstate.Insert(inf.basename,"0");
if ( inf.maxval )
achievementprogress.Insert(inf.basename,"0");
}
}
else if ( e.Name ~== "swwmdumpachievements" )
{
Console.Printf("---STATE---");
let di = DictionaryIterator.Create(achievementstate);
while ( di.Next() )
Console.Printf("%s = %s",di.Key(),di.Value());
Console.Printf("---PROGRESS---");
di = DictionaryIterator.Create(achievementprogress);
while ( di.Next() )
Console.Printf("%s = %s",di.Key(),di.Value());
}
else if ( e.Name ~== "swwmgetversion" )
{
let ti = ThinkerIterator.Create("SWWMSaveVerData",Thinker.STAT_STATIC);
let svd = SWWMSaveVerData(ti.Next());
if ( svd ) Console.Printf("\cj%s\c-",svd.ver);
else Console.Printf("\cg(no version data)\c-");
if ( tainted ) Console.Printf("\cgversion mismatched\c-");
else Console.Printf("\cdversion not mismatched\c-");
}
else if ( e.Name ~== "swwmdumpthinkers" )
{
Array<Class<Thinker> > sdefs;
foreach ( cls : AllClasses )
{
if ( !(cls is 'Thinker') || (cls is 'Actor') || (cls == 'Thinker') )
continue;
sdefs.Push(cls);
}
if ( !e.Args[0] )
{
// trim default gzdoom thinkers
for ( int i=0; i<sdefs.Size(); i++ )
{
if ( sdefs[i].GetClassName() != 'WallLightTransfer' )
continue;
sdefs.Delete(0,i+1);
break;
}
}
Array<int> stink;
stink.Resize(sdefs.Size());
for ( int i=Thinker.STAT_INFO; i<Thinker.MAX_STATNUM; i++ )
{
let ti = ThinkerIterator.Create("Thinker",i);
Thinker t;
while ( t = ti.Next() )
{
if ( t is 'Actor' ) continue;
let cls = t.GetClass();
let p = sdefs.Find(cls);
if ( p >= sdefs.Size() ) continue;
stink[p]++;
}
ti.Destroy();
}
for ( int i=0; i<sdefs.Size(); i++ )
Console.Printf("%s%s%s\c-",stink[i]?"\cj":"\cu",sdefs[i].GetClassName(),(stink[i]>1)?String.Format(" [%d]",stink[i]):"");
}
else if ( e.Name ~== "swwmdumphandlers" )
{
foreach ( cls:AllClasses )
{
if ( !(cls is 'StaticEventHandler') || (cls == 'StaticEventHandler') || (cls == 'EventHandler') )
continue;
bool reg = (cls is 'EventHandler')?EventHandler.Find((Class<EventHandler>)(cls)):StaticEventHandler.Find((Class<StaticEventHandler>)(cls));
Console.Printf("%s%s\c-",reg?"\cj":"\cu",cls.GetClassName());
}
}
else if ( e.Name ~== "swwmtestdlgsize" )
{
let f = Font.GetFont('TewiFont');
let lmp = Wads.FindLumpFullName("language.def_dlg");
Array<String> lst;
lst.Clear();
String dat = Wads.ReadLump(lmp);
dat.Split(lst,"\n",0);
bool skipme = true;
Console.Printf("[default]");
bool fail = false;
foreach ( l:lst )
{
if ( l.Left(7) == "// E1M8" ) skipme = false;
if ( l.Left(5) != "SWWM_" ) continue;
if ( skipme ) continue;
// extract string
int st = l.IndexOf("\"")+1;
int en = l.RightIndexOf("\"");
String line = l.Mid(st,en-st);
//line.Filter(); // DOES NOT WORK, FOR SOME REASON
line.Substitute("\\\"","\"");
line.Substitute("\\c","\c");
BrokenLines bl = f.BreakLines(line,220);
if ( bl.Count() > 4 )
{
Console.Printf("\cg%s [%d]\c-",l.Left(st-4),bl.Count());
fail = true;
}
bl.Destroy();
}
if ( !fail ) Console.Printf("ALL OK");
lmp = Wads.FindLumpFullName("language.es_dlg");
lst.Clear();
dat = Wads.ReadLump(lmp);
dat.Split(lst,"\n",0);
skipme = true;
Console.Printf("[es]");
foreach ( l:lst )
{
if ( l.Left(7) == "// E1M8" ) skipme = false;
if ( l.Left(5) != "SWWM_" ) continue;
if ( skipme ) continue;
// extract string
int st = l.IndexOf("\"")+1;
int en = l.RightIndexOf("\"");
String line = l.Mid(st,en-st);
//line.Filter(); // DOES NOT WORK, FOR SOME REASON
line.Substitute("\\\"","\"");
line.Substitute("\\c","\c");
BrokenLines bl = f.BreakLines(line,220);
if ( bl.Count() > 4 )
{
Console.Printf("\cg%s [%d]\c-",l.Left(st-4),bl.Count());
fail = true;
}
bl.Destroy();
}
if ( !fail ) Console.Printf("ALL OK");
}
}
override void NetworkProcess( ConsoleEvent e )
{
if ( e.IsManual ) return;
if ( e.Name.Left(16) ~== "swwmachievement." )
{
let c = Actor.Spawn("PartyTime",players[e.Args[0]].mo.pos);
c.bSTANDSTILL = true;
if ( e.Args[0] == consoleplayer )
{
c.A_StartSound("misc/achievement",CHAN_ITEM,CHANF_UI|CHANF_OVERLAP,attenuation:0.);
c.A_StartSound("misc/achievement2",CHAN_VOICE,CHANF_UI|CHANF_OVERLAP,attenuation:0.);
}
else
{
Console.Printf(String.Format(StringTable.Localize("$SWWM_CHEEVOREM"),players[e.Args[0]].GetUserName(),StringTable.Localize(e.Name.Mid(16))));
c.A_StartSound("misc/achievement",CHAN_ITEM,CHANF_UI|CHANF_OVERLAP);
c.A_StartSound("misc/achievement2",CHAN_ITEM,CHANF_UI|CHANF_OVERLAP);
}
}
else if ( e.Name ~== "swwmsessionid" )
{
let ti = ThinkerIterator.Create("SWWMSaveVerData",Thinker.STAT_STATIC);
let svd = SWWMSaveVerData(ti.Next());
if ( !uid ) uid = e.Args[0];
if ( svd && !svd.uid ) svd.uid = e.Args[0];
}
}
override void PostUiTick()
{
if ( !uid ) EventHandler.SendNetworkEvent("swwmsessionid",SystemTime.Now());
if ( gamestate != GS_TITLELEVEL ) titlefirst = true; // we skip it
if ( (gametic > 0) && !(gametic%GameTicRate) )
{
let pt = CVar.FindCVar('swwm_playtime');
int ct = pt.GetInt();
pt.SetInt(ct+1);
}
if ( gamestate != GS_LEVEL ) return;
CheckAllAchievements();
if ( gametic != checktic ) return;
String cver = StringTable.Localize("$SWWM_SHORTVER");
if ( tainted )
{
let ti = ThinkerIterator.Create("SWWMSaveVerData",Thinker.STAT_STATIC);
let svd = SWWMSaveVerData(ti.Next());
if ( !svd ) Console.Printf("\cgWARNING:\n \cjSave contains no version data. Issues may happen.\c-");
else
{
Console.Printf("\cgWARNING:\n \cjVersion mismatch with save data. Issues may happen.\c-");
Console.Printf("\cgSaved:\n \cj"..svd.ver.."\c-");
Console.Printf("\cgCurrent:\n \cj"..cver.."\c-");
}
}
}
override void UiTick()
{
// Fancy crash effect
if ( (gamestate == GS_LEVEL) || (gamestate == GS_TITLELEVEL) )
{
wasinmap = true;
timer = 0;
}
else if ( (gamestate == GS_FULLCONSOLE) && ((wasinmap && !players[consoleplayer].viewheight) || (timer > 0)) )
{
wasinmap = false;
if ( timer == 1 )
{
msgpick = Random[UIStuff](1,8);
Console.Printf("\cf%s\c-",StringTable.Localize("$CRASHMSG"..msgpick.."A"));
let hnd = SWWMBrutalHandler(StaticEventHandler.Find("SWWMBrutalHandler"));
if ( hnd && hnd.detected )
{
S_StartSound("crash/glass",CHAN_YOUDONEFUCKEDUP,CHANF_UI|CHANF_NOPAUSE|CHANF_OVERLAP,1,ATTN_NONE);
S_StartSound("crash/glass",CHAN_YOUDONEFUCKEDUP,CHANF_UI|CHANF_NOPAUSE|CHANF_OVERLAP,1,ATTN_NONE);
}
else S_StartSound("crash/crash",CHAN_YOUDONEFUCKEDUP,CHANF_UI|CHANF_NOPAUSE|CHANF_OVERLAP,1,ATTN_NONE);
}
else if ( timer == 70 )
{
Console.Printf("\cf%s\c-",StringTable.Localize("$CRASHMSG"..msgpick.."B"));
S_StartSound("crash/curb",CHAN_YOUDONEFUCKEDUP,CHANF_UI|CHANF_NOPAUSE|CHANF_OVERLAP,1,ATTN_NONE);
}
else if ( timer == 140 )
{
let hnd = SWWMBrutalHandler(StaticEventHandler.Find("SWWMBrutalHandler"));
if ( hnd && hnd.detected ) Console.Printf("\cfYou shouldn't have tried running this with "..hnd.which..".\c-");
else Console.Printf("\cfYou should probably screenshot this error and show it to Marisa.\c-");
Console.Printf("\cfLoaded Version:\n \cj%s\c-",StringTable.Localize("$SWWM_SHORTVER"));
if ( tainted ) Console.Printf("\cfSavegame Version:\n \cj%s\c-",taintver);
}
timer++;
}
}
}