Skip to content

Commit

Permalink
cleanups, lag fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stonedDiscord committed Feb 24, 2016
1 parent 9ac8114 commit 580097c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 81 deletions.
18 changes: 9 additions & 9 deletions AOprivateServer.pbp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<section name="data">
<explorer view="" pattern="8"/>
<log show="1"/>
<lastopen date="2016-02-19 20:24" user="Sven" host="SPC"/>
<lastopen date="2016-02-24 01:19" user="Sven" host="SPC"/>
</section>
<section name="files">
<file name="Common.pb">
Expand All @@ -16,19 +16,19 @@
</file>
<file name="gui.pb">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
<fingerprint md5="032c1115b2d0514df87e892eb53b415f"/>
<fingerprint md5="4e2f294b3f258bc54be41f609fe2861d"/>
</file>
<file name="main.pb">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
<fingerprint md5="8f064b7ab243cb670f3be31c6206353c"/>
<fingerprint md5="041ff2c91649facf4c6216fc33b3e002"/>
</file>
<file name="server_shared.pb">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
<fingerprint md5="19ab0fea9e556c5ce06fea5c131bdac9"/>
</file>
<file name="shared_headers.pb">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
<fingerprint md5="8e7fd111116d632ccd750c069437f46f"/>
<fingerprint md5="e2abe7a5b322ea83cd52869d9a581365"/>
</file>
</section>
<section name="targets">
Expand All @@ -41,8 +41,8 @@
<icon enable="1">..\owner.ico</icon>
<format exe="default" cpu="2"/>
<debugger custom="1" type="ide"/>
<compilecount enable="1" value="1003"/>
<buildcount enable="1" value="128"/>
<compilecount enable="1" value="1040"/>
<buildcount enable="1" value="129"/>
<versioninfo enable="1">
<field0 value="2,%COMPILECOUNT,%BUILDCOUNT,0"/>
<field1 value="2.%COMPILECOUNT.%BUILDCOUNT,0"/>
Expand Down Expand Up @@ -71,12 +71,12 @@
<inputfile value="main.pb"/>
<outputfile value="build\serverDco.exe"/>
<executable value="build\serverDco.exe"/>
<options thread="1"/>
<options thread="1" debug="1"/>
<icon enable="0">owner.ico</icon>
<format exe="console" cpu="0"/>
<debugger custom="1" type="ide"/>
<compilecount enable="1" value="1000"/>
<buildcount enable="1" value="128"/>
<compilecount enable="1" value="1040"/>
<buildcount enable="1" value="129"/>
<versioninfo enable="1">
<field0 value="2,%COMPILECOUNT,%BUILDCOUNT,0"/>
<field1 value="2,%COMPILECOUNT,%BUILDCOUNT,0"/>
Expand Down
40 changes: 19 additions & 21 deletions gui.pb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ Procedure RefreshList(var)
LockMutex(ListMutex)
ResetMap(Clients())
While NextMapElement(Clients())
listicon=ImageID(0)
listicon=Icons(0)
If Clients()\perm
listicon=ImageID(1)
listicon=Icons(1)
EndIf
If Clients()\hack
listicon=ImageID(2)
listicon=Icons(2)
EndIf
AddGadgetItem(#Listview_0,i,Clients()\IP+Chr(10)+GetCharacterName(Clients())+Chr(10)+GetAreaName(Clients())+Chr(10)+Clients()\HD,listicon)
SetGadgetItemData(#Listview_0,i,Clients()\ClientID)
Expand All @@ -25,6 +25,7 @@ Procedure RefreshList(var)
SetGadgetState(#Listview_0,lstate)
EndIf
UnlockMutex(RefreshMutex)
rf=0
EndIf
EndProcedure

Expand Down Expand Up @@ -67,7 +68,7 @@ Repeat ; Start of the event loop
If success
NStatus=Network(0)
EndIf
Event = WaitWindowEvent(LagShield) ; This line waits until an event is received from Windows
Event = WindowEvent() ; This line waits until an event is received from Windows
WindowID = EventWindow() ; The Window where the event is generated, can be used in the gadget procedures
GadgetID = EventGadget() ; Is it a gadget event?
EventType = EventType() ; The event type
Expand Down Expand Up @@ -204,23 +205,20 @@ Repeat ; Start of the event loop
ResizeGadget(#listbox_event, WindowWidth(0)/1.7, 30, WindowWidth(0)-WindowWidth(0)/1.7, WindowHeight(0)-90)
ResizeGadget(#listbox_event,WindowWidth(0)/2.517,20,WindowWidth(0)/3.173,WindowHeight(0)-20)
ResizeGadget(#Frame_5,WindowWidth(0)/1.4,0,WindowWidth(0)/3.476,WindowHeight(0))
ResizeGadget(#ListIcon_2,WindowWidth(0)/1.4,20,WindowWidth(0)/3.476,WindowHeight(0)-40)

ResizeGadget(#ListIcon_2,WindowWidth(0)/1.4,20,WindowWidth(0)/3.476,WindowHeight(0)-40)
ResizeGadget(#String_13,WindowWidth(0)/1.4,WindowHeight(0)-20,WindowWidth(0)/5,20)
ResizeGadget(#Button_31,WindowWidth(0)/1.1,WindowHeight(0)-20,WindowWidth(0)/10,20)


ResizeGadget(#Button_31,WindowWidth(0)/1.1,WindowHeight(0)-20,WindowWidth(0)/10,20)
Else
If rf And chill<1
chill=(LagShield+10)*2
If CommandThreading
CreateThread(@RefreshList(),0)
Else
RefreshList(0)
EndIf
EndIf
chill-1
EndIf

If rf
If CommandThreading
CreateThread(@RefreshList(),0)
Else
RefreshList(0)
EndIf
rf=0
EndIf

Until Event = #PB_Event_CloseWindow ; End of the event loop
Quit=1

Expand All @@ -244,7 +242,7 @@ DataSection
bannerend:
EndDataSection
; IDE Options = PureBasic 5.31 (Windows - x86)
; CursorPosition = 244
; FirstLine = 196
; CursorPosition = 212
; FirstLine = 194
; Folding = -
; EnableXP
70 changes: 21 additions & 49 deletions main.pb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Global opppass$=""
Global Quit=0
Global Port=27016
Global scene$="AAOPublic2"
Global characternumber=0
Global CharacterNumber=0
Global slots$="100"
Global oBG.s="gs4"
Global rt.b=1
Expand Down Expand Up @@ -78,7 +78,7 @@ Global RefreshMutex = CreateMutex()
Global ActionMutex = CreateMutex()
Global musicmode=1
Global update=0
Global Aareas=1
Global AreaNumber=1
Global decryptor$
Global key
Global newbuild
Expand Down Expand Up @@ -447,8 +447,8 @@ Procedure LoadSettings(reload)

If OpenPreferences( "base/scene/"+scene$+"/areas.ini")
PreferenceGroup("Areas")
Aareas=ReadPreferenceInteger("number",1)
For loadareas=0 To Aareas-1
AreaNumber=ReadPreferenceInteger("number",1)
For loadareas=0 To AreaNumber-1
PreferenceGroup("Areas")
aname$=Encode(ReadPreferenceString(Str(loadareas+1),oBG.s))
areas(loadareas)\name=aname$
Expand All @@ -465,7 +465,7 @@ Procedure LoadSettings(reload)
PreferenceGroup("filename")
WritePreferenceString("1",oBG.s)
areas(0)\bg=oBG.s
Aareas=1
AreaNumber=1
ClosePreferences()
EndIf
EndIf
Expand Down Expand Up @@ -636,7 +636,7 @@ Procedure TrackWait(a)
Define stoploop,k,cw
cw=1000
Repeat
For k=0 To Aareas
For k=0 To AreaNumber-1
If Areas(k)\trackwait>1
If Areas(k)\trackwait<cw
cw=Areas(k)\trackwait
Expand All @@ -655,22 +655,13 @@ Procedure TrackWait(a)
EndProcedure

Procedure ListIP(ClientID)
Define send.b
Define iplist$
Define charname$
Define char
send=0
iplist$="IL#"
LockMutex(ListMutex)
PushMapPosition(Clients())
ResetMap(Clients())
While NextMapElement(Clients())
char=Clients()\CID
If char<=100 And char>=0
If char>characternumber ; the character id is greater than the amount of characters
charname$="HACKER" ; OBVIUOSLY
Clients()\hack=1
Else
Select Clients()\perm
Case 1
charname$=GetCharacterName(Clients())+"(mod)"
Expand All @@ -681,12 +672,7 @@ Procedure ListIP(ClientID)
Default
charname$=GetCharacterName(Clients())
EndSelect
EndIf
Else
charname$="nobody"

EndIf
iplist$=iplist$+Clients()\IP+"|"+charname$+"|"+Str(char)+"|*"
iplist$=iplist$+Clients()\IP+"|"+charname$+"|"+Str(Clients()\CID)+"|*"
Wend
PopMapPosition(Clients())
UnlockMutex(ListMutex)
Expand All @@ -695,38 +681,24 @@ Procedure ListIP(ClientID)
EndProcedure

Procedure ListAreas(ClientID)
Define send.b
Define iplist$
Define charname$
Define char
send=0
iplist$="IL#"
LockMutex(ListMutex)
PushMapPosition(Clients())
ResetMap(Clients())
While NextMapElement(Clients())
char=Clients()\area
If char<=100 And char>=0
If char>Aareas ; the character id is greater than the amount of characters
charname$="HACKER"; OBVIUOSLY
Clients()\hack=1
Else
Select Clients()\perm
Case 1
charname$=GetCharacterName(Clients())+"(mod)"
charname$=GetCharacterName(Clients())+"(mod)"+" in "+GetAreaName(Clients())
Case 2
charname$=GetCharacterName(Clients())+"(admin)"
charname$=GetCharacterName(Clients())+"(admin)"+" in "+GetAreaName(Clients())
Case 3
charname$=GetCharacterName(Clients())+"(server)"
charname$=GetCharacterName(Clients())+"(server)"+" in "+GetAreaName(Clients())
Default
charname$=GetCharacterName(Clients())
charname$=GetCharacterName(Clients())+" in "+GetAreaName(Clients())
EndSelect
EndIf
Else
charname$="nobody"

EndIf
iplist$=iplist$+Clients()\IP+"|"+charname$+"|"+Str(char)+"|*"
iplist$=iplist$+Clients()\IP+"|"+charname$+"|"+Str(Clients()\area)+"|*"
Wend
PopMapPosition(Clients())
UnlockMutex(ListMutex)
Expand Down Expand Up @@ -768,7 +740,7 @@ ProcedureDLL MasterAdvert(Port)
msrec$=PeekS(*null,msinfo)
Debug msrec$
If msrec$="NOSERV#%"
WriteLog("Fell of the serverlist, fixing...",Server)
WriteLog("Fell off the serverlist, fixing...",Server)
sr=SendNetworkString(msID,"SCC#"+Str(Port)+"#"+msname$+"#"+desc$+"#serverD "+version$+"#%"+Chr(0))
WriteLog("Server published!",Server)
EndIf
Expand Down Expand Up @@ -845,7 +817,7 @@ EndProcedure
Procedure SwitchAreas(*usagePointer.Client,narea$)
Define ir
Define sendd=0
For ir=0 To Aareas-1
For ir=0 To AreaNumber-1
areas(ir)\players=0
Debug areas(ir)\name
If areas(ir)\name = narea$
Expand Down Expand Up @@ -885,7 +857,7 @@ Procedure SwitchAreas(*usagePointer.Client,narea$)
SendTarget(Str(*usagePointer\ClientID),"HP#1#"+Str(Areas(0)\good)+"#%",Server)
SendTarget(Str(*usagePointer\ClientID),"HP#2#"+Str(Areas(0)\evil)+"#%",Server)
Else
If Val(narea$)<=Aareas-1 And Val(narea$)>=0
If Val(narea$)<=AreaNumber-1 And Val(narea$)>=0
If Not areas(Val(narea$))\lock Or *usagePointer\perm>areas(Val(narea$))\mlock

If areas(*usagePointer\area)\lock=*usagePointer\ClientID
Expand Down Expand Up @@ -1358,7 +1330,7 @@ Procedure HandleAOCommand(*usagePointer.Client)

If narea$=""
arep$="CT#$HOST#Areas:"
For ir=0 To Aareas-1
For ir=0 To AreaNumber-1
arep$+#CRLF$
arep$=arep$+areas(ir)\name+": "+Str(areas(ir)\players)+" users"
If ir=*usagePointer\area
Expand Down Expand Up @@ -1901,8 +1873,8 @@ Procedure HandleAOCommand(*usagePointer.Client)
SendTarget(Str(ClientID),"PV#"+Str(*usagePointer\AID)+"#CID#"+Str(char)+"#%",Server)
*usagePointer\CID=char
WriteLog("chose character: "+GetCharacterName(*usagePointer),*usagePointer)
SendTarget(Str(ClientID),"HP#1#"+Str(Areas(0)\good)+"#%",Server)
SendTarget(Str(ClientID),"HP#2#"+Str(Areas(0)\evil)+"#%",Server)
SendTarget(Str(ClientID),"HP#1#"+Str(Areas(*usagePointer\area)\good)+"#%",Server)
SendTarget(Str(ClientID),"HP#2#"+Str(Areas(*usagePointer\area)\evil)+"#%",Server)
If MOTDevi
SendTarget(Str(ClientID),"MS#chat#normal#Discord#normal#Take that!#jud#1#2#"+Str(characternumber-1)+"#0#3#"+Str(MOTDevi)+"#"+Str(characternumber-1)+"#0#"+Str(modcol)+"#%",Server)
EndIf
Expand All @@ -1924,7 +1896,7 @@ Procedure HandleAOCommand(*usagePointer.Client)
Else
ListIP(ClientID)
EndIf
WriteLog("["+GetCharacterName(*usagePointer)+"] used /ip",*usagePointer)
WriteLog("["+GetCharacterName(*usagePointer)+"] used /ip (clientside)",*usagePointer)
EndIf

Case "opKICK"
Expand Down Expand Up @@ -2391,8 +2363,8 @@ CompilerEndIf

End
; IDE Options = PureBasic 5.31 (Windows - x86)
; CursorPosition = 2391
; FirstLine = 2343
; CursorPosition = 1063
; FirstLine = 1186
; Folding = ---
; EnableXP
; EnableCompileCount = 0
Expand Down
4 changes: 2 additions & 2 deletions serverd.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[Version]
Compile=1024
Build=128
Compile=1040
Build=129
0.0.0.0

0 comments on commit 580097c

Please sign in to comment.