Attribute VB_Name = "modServer" 'Some stuff the server needs Global HoloDB As New HoloDB Global FSO As New FileSystemObject Global funcLib As New clsFunctions Global mapProcessor As New clsMapping Public Const maxMaps As Integer = 600 Public Const maxConnections As Integer = 500 Public Server As appSet Public CONF As String Public pubCounts As pubCountsT Public guestCat(1 To 10) As String Public staticModel(1 To 18) As staticModelT 'Index of models Public mINDEX(1 To maxMaps) As Long 'Index of maps Public mWALK(1 To maxMaps, -1 To 60, 0 To 60) As Byte 'Generated maps of guestrooms (dynamic data) Public mROT(1 To maxMaps, 0 To 60, 0 To 60) As Byte 'Generated maps of guestroom furniture rotation Public mHSIT(1 To maxMaps, 0 To 60, 0 To 60) 'Generated maps of guestroom sitheights 'The profile where the server saves it's settings Public Type appSet sPort As Integer sckCount As Integer freeScks As String onlineCount As Integer onlinePeak As Integer acceptedConnections As Long ssoLogin As Boolean filterEnabled As Boolean filterWord() As String filterReplacement As String forbiddenName() As String roomModels As String rNums As String cCFHs As Long catalogueIndex As String catalogueIndexAdmin As String welcMessage As String End Type 'The profile where the server saves it's public room/category counts Public Type pubCountsT welcomeLounge As Integer safetySpa As Integer sportRoom As Integer theatreDome As Integer hotelKitchen As Integer theDen As Integer hotelCinema As Integer theLibrary As Integer holoLido As Integer holoLido2 As Integer rooftopRumble As Integer holoHarbor As Integer picknickPark As Integer zenGarden As Integer hotelRoof As Integer hotelRoof2 As Integer thePark As Integer infoBus As Integer sakuraSquare As Integer sakuraSquare2 As Integer sunTerrace As Integer cafeOle As Integer galleryCafe As Integer iceCafe As Integer flyingCarrots As Integer theMajestic As Integer dirtyDuck As Integer chromideClub As Integer slinkyMassiva As Integer slinkyDancefloor As Integer lobbyMain As Integer lobbySkylight As Integer lobbyMedian As Integer lobbyBasement As Integer burgerRestaurant As Integer pizzaRestaurant As Integer gameLobby As Integer ticTacToe As Integer battleShips As Integer gamePoker As Integer gameChess As Integer hallwayOne As Integer hallwayTwo As Integer End Type 'The profile where the server saves the static data of guestroom models Public Type staticModelT doorX As Integer doorY As Integer doorH As String strMap As String mapSpot(0 To 60, 0 To 60) As Byte 'Generated maps of guestroom models (static data) End Type Function loadPreferences() 'Load the preferences from the config.ini file 'Load the info for the rank profiles from the rank table in the database Dim rRank() As String For R = 1 To 6 rRank() = Split(HoloDB.runRead("SELECT fuserights,ignorefilter,receivecfh,enterallrooms,seeallowners,admincatalogue,stafffloor,rightseverywhere FROM ranks WHERE rank = '" & R & "'"), Chr(9)) With Rank(R) .fuseRights = rRank(0) If rRank(1) = "1" Then .ignoreFilter = True Else .ignoreFilter = False If rRank(2) = "1" Then .receiveCFH = True Else .receiveCFH = False If rRank(3) = "1" Then .enterAllRooms = True Else .enterAllRooms = False If rRank(4) = "1" Then .seeAllOwners = True Else .seeAllOwners = False If rRank(5) = "1" Then .adminCatalogue = True Else .adminCatalogue = False If rRank(6) = "1" Then .staffFloor = True Else .staffFloor = False If rRank(7) = "1" Then .rightsEverywhere = True Else .rightsEverywhere = False End With Next R 'Load the wordfilter + forbidden words/names details from the system table in the database filterRow = HoloDB.runRead("SELECT filterwords,filtercensor,filterwords_names FROM system") Server.filterWord() = Split(Split(filterRow, Chr(9))(0), ",") Server.filterReplacement = Split(filterRow, Chr(9))(1) Server.forbiddenName() = Split(LCase(Split(filterRow, Chr(9))(2)), ",") 'If filter is set enabled in config.ini then enable in server If ReadINI("game", "wordfilter", CONF) = "1" Then Server.filterEnabled = True Else Server.filterEnabled = False 'Load the login choice If ReadINI("login", "sso", CONF) = "1" Then Server.ssoLogin = True Else Server.ssoLogin = False 'Load the welcome message from system table, if welcome messages are enabled, if not set it to empty so it doesn't show up (setting to empty is required at :rehash command) If ReadINI("login", "welcome_message", CONF) = "1" Then Server.welcMessage = HoloDB.runRead("SELECT welcome_message FROM system") Else Server.welcMessage = "" 'Set default guestroom category names guestCat(1) = "Holo Hotel - Staff floor" guestCat(2) = "Holo Hotel - Trading rooms" guestCat(3) = "Holo Hotel - Chat & chill rooms" guestCat(4) = "Holo Hotel - Club & Groups rooms" guestCat(5) = "Holo Hotel - Gaming & Race rooms" guestCat(6) = "Holo Hotel - Hair salons & modelling rooms" guestCat(7) = "Holo Hotel - Maze & Themepark rooms" guestCat(8) = "Holo Hotel - Food and drinks" guestCat(9) = "Holo Hotel - Schools and daycares" guestCat(10) = "Holo Hotel - Other rooms" End Function Function stopUser(Index As Integer) 'If you login, and you are already logged in somewhere else, disconnect your previous login 'Go through all sockets For u = 1 To Server.sckCount 'Cheak if the users name where the count is at the moment, is equal to the name we're searching If Holo(Index).Name = Holo(u).Name And Index <> u Then 'The user is found, and logged in! Disconnect him! hSYS.closeSocket Index End If Next u 'Sometimes there are more of them, odd, but let's go again! End Function Function findSocket(userID As Integer) As Integer For x = 1 To Server.sckCount If userID = Holo(x).ID Then findSocket = x Exit For End If Next x End Function Function loadRoomModels() Dim modelID As Integer, rModel As String, MPR() As String 'Set model index Server.roomModels = "|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|" 'Load the static model data in the memory, render the map in an array For modelID = 1 To 18 rModel = Split(Server.roomModels, "|")(modelID) rRow = HoloDB.runRead("SELECT door,static FROM guestroom_modeldata WHERE model = '" & rModel & "'") rDoor = Split(rRow, Chr(9))(0) staticModel(modelID).doorX = Split(rDoor, ",")(0) staticModel(modelID).doorY = Split(rDoor, ",")(1) staticModel(modelID).doorH = Split(rDoor, ",")(2) staticModel(modelID).strMap = Replace(Split(rRow, Chr(9))(1), Chr(2), Chr(13)) Dim sX As Integer, sY As Integer, mapPart() As String mapPart() = Split(staticModel(modelID).strMap, Chr(13)) For sY = 1 To UBound(mapPart) - 1 For sX = 1 To Len(mapPart(sY)) sCheck = Mid(mapPart(sY), sX, 1) If sCheck = "x" Then sCheck = 20 Else sCheck = Val(sCheck) staticModel(modelID).mapSpot(sX - 1, sY) = sCheck Next sX Next sY Next modelID End Function Function modelID(modelLetter As String) As Integer 'Convert a model letter to a number, so you can read it from the profile for static maps For x = 1 To 255 If modelLetter = Chr(x) Then modelID = x - 96 Exit For End If Next x End Function Function rehashCatalogue() Dim cPage() As String, donePages As String 'Dump and recreate the folder folPath = App.Path & "\bin\catalogue" If FSO.FolderExists(folPath) = True Then FSO.DeleteFolder (folPath) FSO.CreateFolder folPath cIndex = Replace(HoloDB.runRead("SELECT catalogue_index FROM system"), Chr(129), "'") 'Get the index from the database, filter the Chr(129) characters to ' cIndexExtra = Replace(HoloDB.runRead("SELECT catalogue_index_admin FROM system"), Chr(129), "'") Server.catalogueIndex = cIndex Server.catalogueIndexAdmin = cIndexExtra cIndex = Replace(cIndex & cIndexExtra, ";;", ";") 'Merge them and remove double ; cPage() = Split(cIndex, ";") For C = 0 To UBound(cPage) pageName = cPage(C) If pageName <> "" And InStr(donePages, "/" & pageName & "/") = False Then pageDat = Replace(HoloDB.runRead("SELECT content FROM catalogue WHERE tab = '" & pageName & "'"), Chr(129), "'") If pageDat <> "" Then FSO.OpenTextFile(folPath & "\page_" & pageName & ".bin", ForWriting, True).Write pageDat donePages = donePages & "/" & pageName & "/" End If Next C 'Get the sprite index from the database and write to binary file in /catalogue/ folder sIndex = HoloDB.runRead("SELECT furniture_index FROM system") FSO.OpenTextFile(folPath & "\index_sprites.bin", ForWriting, True).Write sIndex End Function Function sendGuestRoom(roomID As Long, strData As String) For x = 1 To Server.sckCount If hSYS.sckGame(x).State = sckConnected And Holo(x).guestRoom = roomID Then hSYS.sckGame(x).SendData strData Next x End Function Function sendPublicRoom(roomID As Integer, strData As String) For x = 1 To Server.sckCount If hSYS.sckGame(x).State = sckConnected And Holo(x).publicRoom = roomID Then hSYS.sckGame(x).SendData strData Next x End Function