Hey guys, I havent been on here in forever. Partially because my partner really wanted to do something different and I had a bug in Desolation that seemed totally random so progress on it stopped entirely. But I opened the source the other day and tried to work on it. To figure out this random bug, Ive been trying to write logs, but those are always random too. I know this seems like a lot, which it is, but Im gonna post all my code here, and hopefully someone can spot this. Ive spent so many hours on just trying to fix this. Ive commented it where you can see the :"pages" The crash happens on the join lobby page either when you clcik on the accept button or you hit enter after entering your name.
The GUI is BBB GUI.
CLIENT
DesolationGame.dba
REM Project: Desolation
REM Created: 1/6/2010 5:02:30 PM
REM
REM ***** Main Source File *****
REM
`Set Sync Rate On
Set Display Mode 1024,768,32
Set Window On
`Autocam off
Autocam off
`=================Type Declaration====================
`Basic Unit Type - Used for Selections
`BasicUnits Type.ID corresponds with Object Number
Type BasicUnit
ID as Integer `ID of the object
MaxHealth as Integer `Maximum health of the unit
Health as Integer `Current health of the unit
Task as Integer `Current task of unit
Category as String `Category/Type of unit
MaxEnergy as Integer `Max energy of the unit
Energy as Integer `Current energy the unit has
Team as Integer `Team that the unit belongs to
TeamColorR as Integer `Red value of the color of the team
TeamColorB as Integer `Blue value of the color of the team
TeamColorG as Integer `Green value of the color of the team
CurrentTarget as Integer `Current target/enemy of the unit
XPosition# as Float `Current x position of the unit
YPosition# as Float `Current y position of the unit
ZPosition# as Float `Current z position of the unit
TargetXPosition# as Float `Target x position of the moving unit
TargetZPosition# as Float `Target z position of the moving unit
Selected as Integer `Is the unit selected or not
Moving as Integer `Is the unit moving or not
Speed# as Float `Speed of the unit
Armor as integer `Armor amount of the unit
Range as integer `Range of the unit
AttackPower as Integer `Base attackpower of the unit
SelectionSound as Integer `Sound played when unit is selected
SelectionPlaneID `Selection Circle Plane ID
DidMakeSelectionPlane `Did they make a selection plane
SelectionPlaneScale# `Scale of the selection plane
EndType
Dim BasicUnits(100) as BasicUnit
`Player type for connected users
Type Player
ID as integer
UserName$ as String
Team$ as String
IsHost as Integer `1 = yes, 2 = no
EndType
Dim usersConnected$(2) as Player
`Lobby chat messages
Dim lobbyChatArrayMessages$(1000)
`Lobby combox team selection
Type teamSelectionLobby
ID as Integer
correspondingPlayerID as Integer
EndType
Dim arrLobbyTeamSelection(4) as teamSelectionLobby
`====================================================
`Load all the media at the beginning necessary for initial use
LoadMedia()
Sync On
SYNC RATE 100
`Start the GUI
start bbb gui
`Load the dll for use in lobby
load dll "user32.dll", 1
`For the premenu
Setup_PreMainMenu = 0
Image_PreMenu_Animation = 21
clickStartGame = -1
open log "c:\logDes.txt"
Do
`Handles closing of the progam by "X" Button
repeat
dbpro_w=get dbpro window() : set main window dbpro_w
get event
h=event get handle()
m=event get message()
if h=get main window()
if m=WM_CLOSE
execute file "taskkill.exe", "/F /IM DesolationServer.exe", ""
end bbb gui
end
endif
endif
until m=0
HandleNetwork()
`Keep at top of loop
If clickStartGame = -1
PreMainMenu()
EndIf
If clickStartGame = 0
cls
MainMenu()
s#=scrolltext(0,0,screen width(),MySQL_GetRowDataByColName(0, "message"),s#,1.0,15,"Arial")
EndIf
If clickStartGame = 1
`Lobby
Lobby()
EndIf
If clickStartGame = 2 and net connected()
`Set up game
SetUpGame()
clickStartGame = 3
EndIf
If clickStartGame = 4
CreateLobbyPage()
ENDIF
If clickStartGame = 5
JoinLobby()
ENDIF
If clickStartGame = 6
SettingsPage()
ENDIF
`USED TO START DRAWING 3D STUFF!
If clickStartGame = 3
`Camera Movement
RTSCamera(.8)
`Print fps
ink rgb(255,255,255),rgb(255,255,255)
text 0,0,str$(screen fps())
text 0,15,"Users Connected:"
For i = 1 to MAX_CONNECTIONS
text 0,30 + ((i*10)+15),usersConnected$(i).UserName$
NEXT i
`Calculate ping
if ticker(1) > 0
`Packet contains byte, username of client, and systemt time
NET PUT BYTE MESSAGE_PING
NET PUT STRING UserName$
NET PUT INT timer()
NET SEND
DELETE TICKER 1
MAKE TICKER 1,5000
EndIf
`Print ping to screen
text 0,100,"Ping: " + str$(myClientPing)
`==================Select and Move Objects===============
object = pick object( mousex(), mousey(), 1, 100)
`selectionCircle = FreeObject()
IF mouseclick() = 0
resetMouse = 0
ENDIF
`Left mouse button and control button for single select
IF mouseclick() = 1 and object > 0 AND resetMouse = 0 and controlkey() = 1
resetMouse = 1
inArray = 0
FOR searchArray = 1 to 100
IF BasicUnits( searchArray ).ID = object and BasicUnits( searchArray ).Selected = 1
`Object is alread in array so its already selected
`Set inArray to the number of the object selected and continue
inArray = searchArray
ENDIF
NEXT searchArray
IF inArray > 0
`If its already selected color the object and set its selected property to 0
`deselect object
color object object, rgb(255,255,255)
BasicUnits( inArray ).Selected = 0
ENDIF
IF inArray = 0
`If not already in array, its not selected
FOR findOpenSlot = 1 to 100
`If the Selected value of the object is equal to 0
IF BasicUnits( findOpenSlot ).Selected = 0 and BasicUnits( findOpenSlot ).ID = object
`color the object pink for selected
color object object, rgb(255,127,80)
`Set the loop number to openSlot because that number is free
openSlot = findOpenSlot
findOpenSlot = 100
ENDIF
NEXT findOpenSlot
`Set the selected property to 1
BasicUnits( openSlot ).Selected = 1
BasicUnits( openSlot ).XPosition# = Object Position X(BasicUnits( openSlot ).ID)
BasicUnits( openSlot ).YPosition# = Object Position Y(BasicUnits( openSlot ).ID)
BasicUnits( openSlot ).ZPosition# = Object Position Z(BasicUnits( openSlot ).ID)
` Make Object Cylinder selectionCircle, 3
`position object selectionCircle, BasicUnits( openSlot ).XPosition#, BasicUnits( openSlot ).YPosition#, BasicUnits( openSlot ).ZPosition#
ENDIF
ENDIF
remstart
`Deselect all objects with a left mouse click on no objects
IF mouseclick() = 1 and object <= 0 AND resetMouse = 0 and controlkey() <> 1
`Clicked on nothing with the right mouse button. Clear the selection property of each object
FOR searchArray = 1 to 100
if BasicUnits( searchArray ).ID <> 0
color object searchArray, rgb(255,255,255)
`Set all objects to be deselected
BasicUnits( searchArray ).Selected = 0
EndIf
NEXT searchArray
ENDIF
remend
_mouse_click = mouseclick()
if _mouse_click = 1 and selectionFlag = 0 and controlkey() <> 1
selectionFlag = 1
bx = mouseX()
by = mouseY()
endif
if _mouse_click = 1 and selectionFlag = 1
bx2 = mouseX()
by2 = mouseY()
endif
if _mouse_click <> 1 then selectionFlag = 0
if selectionFlag = 1
rem sort the coordinates
if bx < bx2
bx0 = bx
bx1 = bx2
else
bx0 = bx2
bx1 = bx
endif
if by < by2
by0 = by
by1 = by2
else
by0 = by2
by1 = by
endif
rem draw a box
line bx0, by0, bx1, by0
line bx0, by1, bx1, by1
line bx0, by0, bx0, by1
line bx1, by0, bx1, by1
for x = 1 to 100
If BasicUnits( x ).ID > 0
cx = object screen x(BasicUnits(x).ID)
cy = object screen y(BasicUnits(x).ID)
rem if character is within the selection box..
if cx > bx0 and cx < bx1 and cy > by0 and cy < by1
BasicUnits(x).Selected = 1
color object BasicUnits(x).ID, rgb(255,127,80)
else
BasicUnits(x).Selected = 0
color object BasicUnits(x).ID, rgb(255,255,255)
endif
EndIf
Next x
endif
`If right mouseclick
IF mouseclick() = 2 AND resetMouse = 0
resetMouse = 1
`Translate 2d mouse coords to 3d
pick screen mousex(),mouseY(),1000
vx# = get pick vector x()
vy# = get pick vector y()
vz# = get pick vector z()
dy# = -camera position y()/vy#
vx# = vx#*dy# + camera position x()
vz# = vz#*dy# + camera position z()
`Loop through BasicUnits array
FOR searchArray = 1 to 100
`If the current iteration object is selected
IF BasicUnits( searchArray ).Selected = 1
`Set its target position, set by the 3d vectors by the mouse
`Also set its Moving property to 1, so it is moving
BasicUnits( searchArray ).TargetXPosition# = vx#
BasicUnits( searchArray ).TargetZPosition# = vz#
BasicUnits( searchArray ).Moving = 1
ENDIF
NEXT searchArray
ENDIF
`Create plane beneath object for selection circle
for s = 1 to 100
If BasicUnits(s).DidMakeSelectionPlane = 1 and BasicUnits( s ).ID > 0 and BasicUnits( s ).Selected = 1
position object BasicUnits( s ).SelectionPlaneID, BasicUnits( s ).XPosition#, BasicUnits( s ).YPosition# - object size y(BasicUnits( s ).ID) * .5, BasicUnits( s ).ZPosition#
`Rotate Object BasicUnits( s ).SelectionPlaneID, OBJECT ANGLE X(BasicUnits( s ).ID), OBJECT ANGLE Y(BasicUnits( s ).ID), OBJECT ANGLE Z(BasicUnits( s ).ID)
BasicUnits(s).SelectionPlaneScale# = (object size(BasicUnits( s ).ID) * 100)
SCALE OBJECT BasicUnits(s).SelectionPlaneID,BasicUnits(s).SelectionPlaneScale#,BasicUnits(s).SelectionPlaneScale#,BasicUnits(s).SelectionPlaneScale#
`Spin
YROTATE OBJECT BasicUnits( s ).SelectionPlaneID, OBJECT ANGLE Y(BasicUnits( s ).SelectionPlaneID) + .2
EndIf
If BasicUnits(s).DidMakeSelectionPlane = 1 and BasicUnits( s ).ID > 0 and BasicUnits( s ).Selected = 0
`Deselected
Delete Object BasicUnits( s ).SelectionPlaneID
BasicUnits(s).DidMakeSelectionPlane = 0
ENDIF
If BasicUnits( s ).ID > 0 and BasicUnits( s ).Selected = 1 and BasicUnits(s).DidMakeSelectionPlane = 0
SelectionPlaneID = FreeObject()
BasicUnits( s ).SelectionPlaneID = SelectionPlaneID
MAKE OBJECT PLAIN BasicUnits(s).SelectionPlaneID, 3,3
TEXTURE OBJECT BasicUnits(s).SelectionPlaneID, Image_Selection_Circle
XROTATE OBJECT BasicUnits( s ).SelectionPlaneID,90.0
GHOST OBJECT ON BasicUnits( s ).SelectionPlaneID
position object BasicUnits( s ).SelectionPlaneID, BasicUnits( s ).XPosition#, BasicUnits( s ).YPosition# - object size y(BasicUnits( s ).ID) * .5, BasicUnits( s ).ZPosition#
`BasicUnits(s).SelectionPlaneScale# = (object size(BasicUnits( s ).ID) * 100)
`SCALE OBJECT BasicUnits(s).SelectionPlaneID,BasicUnits(s).SelectionPlaneScale#,BasicUnits(s).SelectionPlaneScale#,BasicUnits(s).SelectionPlaneScale#
BasicUnits(s).DidMakeSelectionPlane = 1
EndIf
NEXT s
`Loop through the array to move every object that is selected and its moving property is true
FOR searchArray = 1 to 100
IF BasicUnits( searchArray ).Moving = 1
Point Object BasicUnits( searchArray ).ID, BasicUnits( searchArray ).TargetXPosition#, 0, BasicUnits( searchArray ).TargetZPosition#
Move Object BasicUnits( searchArray ).ID, BasicUnits( searchArray ).Speed#
BasicUnits( searchArray ).XPosition# = Object Position X(BasicUnits( searchArray ).ID)
BasicUnits( searchArray ).YPosition# = Object Position Y(BasicUnits( searchArray ).ID)
BasicUnits( searchArray ).ZPosition# = Object Position Z(BasicUnits( searchArray ).ID)
ENDIF
If ABS(BasicUnits( searchArray ).XPosition# - BasicUnits( searchArray ).TargetXPosition#) < .1 AND ABS(BasicUnits( searchArray ).ZPosition# - BasicUnits( searchArray ).TargetZPosition#) < .1
`They have reached the target position
BasicUnits( searchArray ).Moving = 0
ENDIF
NEXT searchArray
`==================Select and Move Objects===============
`LEAVE AT THE END!
ENDIF
Sync
Loop
Function SetUpGame()
`Stop Music From lobby
stop music Sound_PrivateReflection
`Load the game media
LoadGameMedia()
cls
`Delete the lobby windows
Delete Window ChatTextBox
Delete Window SendChatText
Delete Window ChatLobbyMessageBox
Sync On
Sync Rate 100
if matrix exist(1) = 0
Make Matrix 1,200,200,20,20
EndIf
`Position and Point Camera
XRotate Camera 45
YRotate Camera 45
Position Camera 0,50,0
load object "MEDIA\Models\darktank.x",1
load object "MEDIA\Models\bluetank.x",2
MAKE OBJECT Cube 3,4
`========EVENTUALLY WHEN CREATING OBJECTS, THIS NEEDS TO BE MOVED===========
BasicUnits( 1 ).Speed# = .2
BasicUnits( 2 ).Speed# = .1
BasicUnits( 3 ).Speed# = .15
`========EVENTUALLY WHEN CREATING OBJECTS, THIS NEEDS TO BE MOVED===========
BasicUnits( 1 ).ID = 1
BasicUnits( 1 ).Team = 1
BasicUnits( 2 ).ID = 2
BasicUnits( 2 ).Team = 2
BasicUnits( 3 ).ID = 3
BasicUnits( 3 ).Team = 2
`==========================================
`=======================================================
Position object 2,0,0,30
POSITION OBJECT 3,30,0,30
`Ping ticker
MAKE TICKER 1,5000
ENDFUNCTION
module_Functions.dba
Rem ***** Included Source File *****
#CONSTANT MAX_CONNECTIONS 2
#CONSTANT MESSAGE_ID_PLAYERJOINED 3
#CONSTANT MESSAGE_ID_PLAYERQUIT 4
#CONSTANT MESSAGE_GET_NAME 5
`#CONSTANT MESSAGE_HOST_START_GAME_BUTTON 6
#CONSTANT MESSAGE_LOBBY_CHAT 7
#CONSTANT MESSAGE_START_GAME_TIMER 8
#CONSTANT MESSAGE_TEAM_SELECTION_CHANGED 9
#CONSTANT MESSAGE_PING 10
`==================VERY IMPORTANT==========================
GLOBAL clickStartGame
`-1 = premainmenu 0 = main menu 1 = Lobby 2 = SetUpGame 3 = Get Out and Run Game 4 = create lobby page
`5 = join lobby page 6 = settings page
GLOBAL ServerName$
GLOBAL playerID
GLOBAL PassWord$
GLOBAL totalConnections
GLOBAL arrayPlace
GLOBAL ServerIp$
GLOBAL UserName$
GLOBAL PassWordFromJoinLobby$
GLOBAL currentStartTime
GLOBAL myClientPing
`===========================================================================
`====================MEDIA GLOBALS================
GLOBAL Sound_PrivateReflection = 1
GLOBAL Sound_Dangerous = 2
GLOBAL Image_Lobby_Back = 1
GLOBAL Image_Main_Menu_Background = 2
GLOBAL Image_Create_Lobby_Basic = 3
GLOBAL Image_Join_Lobby_Basic = 4
GLOBAL Image_Settings_Main_Menu = 5
GLOBAL Image_Exit_Game_Main_Menu = 6
GLOBAL Image_Create_Lobby_Basic_Rollover = 7
GLOBAL Image_Join_Lobby_Basic_Rollover = 8
GLOBAL Image_Settings_Main_Menu_Rollover = 9
GLOBAL Image_Exit_Game_Main_Menu_Rollover = 10
GLOBAL Image_Lobby_Exit_MouseOver = 11
GLOBAL Image_Lobby_Start_MouseOver = 12
GLOBAL Image_Lobby_Start_Disabled = 13
GLOBAL Image_Create_Lobby_Background = 14
GLOBAL Image_Create_Lobby_Accept_Mouseover = 15
GLOBAL Image_Create_Lobby_Cancel_Mouseover = 16
GLOBAL Image_Join_Lobby_Backround = 19
GLOBAL Image_Main_Settings_Page = 20
GLOBAL Image_PreMenu_Animation = 21
GLOBAL Image_Create_Lobby_UP_Fade = 17
GLOBAL Image_Create_Lobby_UP_Fade_Alpha = 255
GLOBAL Image_Create_Lobby_UP_Fade_Init_FadeOut = 1
GLOBAL Image_Create_Lobby_HB_Fade = 18
GLOBAL Image_Create_Lobby_HB_Fade_Alpha = 0
GLOBAL Image_Create_Lobby_HB_Fade_Init_FadeOut = 0
`=========================================
`Used for the lobby page
GLOBAL Setup_LobbyGUI = 0
GLOBAL ChatTextBox
GLOBAL SendChatText
GLOBAL totalLobbyChatMessages
GLOBAL ChatLobbyMessageBox
GLOBAL isSetUpPassLobby
GLOBAL CheckPassButton
GLOBAL LobbyPass
GLOBAL CheckPassButton
`Used for setting up the create lobby page
GLOBAL Setup_CreateLobbyPage1 = 0
GLOBAL ServerNameTextBox
GLOBAL PasswordTextBox
GLOBAL GameTypeComboBox
GLOBAL MapTypeComboBox
`Used for the join lobby page
GLOBAL Setup_CreateJoinLobbyPage1 = 0
GLOBAL IPTextBox
GLOBAL PasswordJoinLobbyTextBox
`Used for premainmenu
GLOBAL Setup_PreMainMenu = 0
`Used for main menu
GLOBAL Setup_Already_Init_MySQL = 0
Function RTSCamera(Speed#)
if (mousex() >= 1015)
Move Camera Right 0.5*Speed#
Endif
if (mousex() <= 7)
Move Camera Left 0.5*Speed#
Endif
if (mousey() <= 7)
Move Camera Up 0.5*Speed#
move camera 0.5*Speed#
Endif
if (mousey() >= 758)
Move Camera Down 0.5*Speed#
move camera -0.5*Speed#
Endif
Position camera camera position x(),camera position y(),camera position z()
Endfunction
`=====================================================================================================
`= =
`= =
`= Handle Network =
`= =
`= =
`=====================================================================================================
Function HandleNetwork()
`If conencted to the server
if net connected()
`While there is an incoming message from the server
while net get message()
`select case statment with the first data byte received to determine what actions to do
select net get byte()
`MESSAGE_ID_PLAYERJOINED = 3 - if a player joined
case MESSAGE_ID_PLAYERJOINED
ServerName$ = net get string()
PassWord$ = NET GET STRING()
totalConnections = net get byte()
arrayPlace = net get byte()
playerID = net get byte()
loopControlVar = 0
writeln log "Player recieved from server"
while loopControlVar = 0
if PassWord$ <> "" and clickStartGame <> 1 and clickStartGame <> 5
HIDE Window ServerNameTextBox
HIDE Window PasswordTextBox
HIDE Window GameTypeComboBox
HIDE Window MapTypeComboBox
If clickStartGame <> 4
if isSetUpPassLobby = 0
`Create textbox for password
IsPassWordSetup()
isSetUpPassLobby = 1
EndIf
PopupMessage((screen width() - 500)/2, (screen height() - 300)/2, 300, 500, "Server Requires Password: ", rgb(128,128,128), rgb(0,0,0))
EndIf
If clickStartGame = 4
usersConnected$(arrayPlace).ID = playerID
If usersConnected$(playerID).ID = 1
`Player is host
usersConnected$(playerID).IsHost = 1
EndIf
net put byte MESSAGE_GET_NAME
net put string UserName$
net put byte arrayPlace
net put byte playerID
net send
isSetUpPassLobby = 0
loopControlVar = 1
clickStartGame = 1
Setup_CreateLobbyPage1 = 0
EndIf
If (button clicked(CheckPassButton)) and (WINDOW GET TEXT(LobbyPass) = PassWord$)
`They got the correct password! Connect them.
`Password string is empty, so connect the user
usersConnected$(arrayPlace).ID = playerID
If usersConnected$(playerID).ID = 1
`Player is host
usersConnected$(playerID).IsHost = 1
EndIf
net put byte MESSAGE_GET_NAME
net put string UserName$
net put byte arrayPlace
net put byte playerID
net send
DELETE WINDOW LobbyPass
DELETE WINDOW CheckPassButton
Delete Window ServerNameTextBox
Delete Window PasswordTextBox
Delete Window GameTypeComboBox
Delete Window MapTypeComboBox
isSetUpPassLobby = 0
loopControlVar = 1
clickStartGame = 1
Setup_CreateLobbyPage1 = 0
EndIf
If (button clicked(CheckPassButton)) and WINDOW GET TEXT(LobbyPass) <> PassWord$
`Password is wrong! Tell them and move them to the main menu
`Disconnect them from server!
NET DISCONNECT
DELETE WINDOW LobbyPass
DELETE WINDOW CheckPassButton
Delete Window ServerNameTextBox
Delete Window PasswordTextBox
Delete Window GameTypeComboBox
Delete Window MapTypeComboBox
clickStartGame = 0
isSetUpPassLobby = 0
loopControlVar = 1
Setup_CreateLobbyPage1 = 0
if sprite exist(1)
DELETE SPRITE 1
EndIf
If sprite exist(2)
DELETE SPRITE 2
EndIf
EndIf
EndIf
If PassWord$ = "" and clickStartGame <> 1 and PassWordFromJoinLobby$ = ""
`Password string is empty, so connect the user
DELETE WINDOW LobbyPass
DELETE WINDOW CheckPassButton
Delete Window ServerNameTextBox
Delete Window PasswordTextBox
Delete Window GameTypeComboBox
Delete Window MapTypeComboBox
Delete Window ChatTextBox
Delete Window SendChatText
Delete Window ChatLobbyMessageBox
usersConnected$(arrayPlace).ID = playerID
If usersConnected$(playerID).ID = 1
`Player is host
usersConnected$(playerID).IsHost = 1
EndIf
net put byte MESSAGE_GET_NAME
net put string UserName$
net put byte arrayPlace
net put byte playerID
net send
clickStartGame = 1
isSetUpPassLobby = 0
loopControlVar = 1
Setup_CreateLobbyPage1 = 0
EndIf
`This client is already in the lobby
If clickStartGame = 1
usersConnected$(arrayPlace).ID = playerID
If usersConnected$(playerID).ID = 1
`Player is host
usersConnected$(playerID).IsHost = 1
EndIf
isSetUpPassLobby = 0
loopControlVar = 1
clickStartGame = 1
Setup_CreateLobbyPage1 = 0
ENDIF
If clickStartGame = 5
writeln log "Joining from lobby"
usersConnected$(arrayPlace).ID = playerID
If usersConnected$(playerID).ID = 1
`Player is host
usersConnected$(playerID).IsHost = 1
EndIf
`theyre joing from the join lobby page!
If PassWordFromJoinLobby$ = PassWord$
`Connect them, right password
net put byte MESSAGE_GET_NAME
net put string UserName$
net put byte arrayPlace
net put byte playerID
net send
writeln log "Sent info to get player name from server"
isSetUpPassLobby = 0
writeln log "isSetUpPassLobby = 0"
loopControlVar = 1
writeln log "loopControlVar = 1"
clickStartGame = 1
writeln log "clickStartGame = 1"
Setup_CreateJoinLobbyPage1 = 0
writeln log "Setup_CreateJoinLobbyPage1 = 0"
EndIf
IF PassWordFromJoinLobby$ <> PassWord$
`Kick them, wrong password
NET DISCONNECT
HIDE WINDOW IPTextBox
HIDE WINDOW PasswordJoinLobbyTextBox
`Tell them they got the wrong password
PopupMessage((screen width() - 500)/2, (screen height() - 300)/2, 300, 500, "Wrong Password!", rgb(128,128,128), rgb(0,0,0))
WAIT 3000
Show WINDOW IPTextBox
Show WINDOW PasswordJoinLobbyTextBox
`take them back to the join lobby page
isSetUpPassLobby = 0
loopControlVar = 1
clickStartGame = 5
Setup_CreateJoinLobbyPage1 = 0
EndIf
ENDIF
endwhile
endcase
case MESSAGE_ID_PLAYERQUIT
playerleft = net get byte()
usersConnected$(playerleft).UserName$ = ""
usersConnected$(playerleft).ID = -1
totalConnections = totalConnections - 1
endcase
case MESSAGE_GET_NAME
For s = 1 to totalConnections
usersConnected$(s).UserName$ = net get string()
Next s
endcase
case MESSAGE_LOBBY_CHAT
`Message received from server for chat in lobby
text$ = NET GET STRING()
If text$ <> ""
lobbyChatArrayMessages$(totalLobbyChatMessages) = text$
totalLobbyChatMessages = totalLobbyChatMessages + 1
EndIf
if clickStartGame = 1
strs$ = window get text(ChatLobbyMessageBox) + chr$(13) + chr$(10) + lobbyChatArrayMessages$(totalLobbyChatMessages-1)
window set text ChatLobbyMessageBox, strs$
//Simulate key press
SET FOCUS WINDOW ChatLobbyMessageBox
call dll 1, "keybd_event",0x22,0,0,0
wait 0
call dll 1, "keybd_event",0x22,0,KEYEVENTF_KEYUP,0
SET FOCUS WINDOW ChatTextBox
EndIf
endcase
case MESSAGE_START_GAME_TIMER
currentStartTime = net get int()
`Get current timer click for starting the game
if currentStartTime <= 0
`Timer is up, send them to setting up the game
clickStartGame = 2
For s = 1 to array count(arrLobbyTeamSelection())
DELETE WINDOW arrLobbyTeamSelection(s).ID
NEXT s
Delete Window ChatTextBox
Delete Window SendChatText
Delete Window ChatLobbyMessageBox
EndIf
endcase
case MESSAGE_TEAM_SELECTION_CHANGED
`Lobby - someone change their team
arrayplace = net get int()
team$ = net get string()
usersConnected$(arrayplace).Team$ = team$
`Set the combobox to the correct selection
If team$ = "United People's Army"
index = 0
EndIf
If team$ = "Highbourne"
index = 1
EndIf
COMBOBOX SET SELECTED ITEM arrLobbyTeamSelection(arrayplace).ID,index
endcase
case MESSAGE_PING
`Received packet of ping info.
`Print to screen
user$ = NET GET STRING()
packetTime = NET GET INT()
myClientPing = timer() - packetTime
endcase
endselect
endwhile
ENDIF
ENDFUNCTION
Function IsPassWordSetup()
isSetUpPassLobby = 0
dbpro_w=get dbpro window() : set main window dbpro_w
`For reference
`PopupMessage((screen width() - 500)/2, (screen height() - 300)/2, 300, 500, "Server Requires Password: ", rgb(128,128,128), rgb(0,0,0))
LobbyPass=make editbox((screen width() - 220)/2 - 40,((screen height() - 300)/2) + 175 ,220,20,ES_MULTILINE||WS_VSCROLL,dbpro_w)
CheckPassButton = make button((screen width() - 220)/2 + 185,((screen height() - 300)/2) + 175,75,20,"Connect",dbpro_w)
ENDFUNCTION
`=====================================================================================================
`= =
`= =
`= Main Menu =
`= =
`= =
`=====================================================================================================
Function MainMenu()
if Setup_Already_Init_MySQL <> 1
SetupMainMenu()
Setup_Already_Init_MySQL = 1
EndIf
`Check for create lobby sprites
if sprite exist(1)
DELETE SPRITE 1
EndIf
If sprite exist(2)
DELETE SPRITE 2
EndIf
`Main Menu Music
loop music Sound_Dangerous
STOP MUSIC Sound_PrivateReflection
`load original buttons
paste image Image_Main_Menu_Background,0,0
paste image Image_Create_Lobby_Basic,40,275,1
paste image Image_Join_Lobby_Basic,40,330,1
paste image Image_Settings_Main_Menu,40,385,1
paste image Image_Exit_Game_Main_Menu,40,440,1
box 0,0,screen width(), 15,RGB(135,137,128),RGB(135,137,128),RGB(135,137,128),RGB(135,137,128)
dbhost$ = "SERVER=localhost;"
dbuser$ = "USER=root;"
dbpass$ = "PASSWORD=root;"
dbname$ = "DATABASE=desolation;"
dbdriver$ = "DRIVER=MySQL ODBC 5.1 Driver;"
dboption$ = "OPTION=3;"
test=MySQL_SetConnection(dbdriver$+dbhost$+dbname$+dbuser$+dbpass$+dboption$)
iRows = MySQL_RunStatement("SELECT * FROM desolationtable")
`Mouseovers
If mousex() >= 86 and mousex() <= 429 and mousey() >= 283 and mousey() <=327
paste image Image_Create_Lobby_Basic_Rollover,40,275,1
If mouseclick() = 1
clickStartGame = 4
cls
EndIf
EndIf
If mousex() >= 86 and mousex() <= 343 and mousey() >= 341 and mousey() <=379
paste image Image_Join_Lobby_Basic_Rollover,40,330,1
If mouseclick() = 1
`Mouseclick
`Join the lobby
`stop music Sound_Dangerous
`TryServerConnect(ServerIp$)
clickStartGame = 5
cls
EndIf
EndIf
If mousex() >= 86 and mousex() <= 300 and mousey() >= 397 and mousey() <=435
paste image Image_Settings_Main_Menu_Rollover,40,385,1
If mouseclick() = 1
clickStartGame = 6
EndIf
EndIf
If mousex() >= 86 and mousex() <= 339 and mousey() >= 452 and mousey() <=493
paste image Image_Exit_Game_Main_Menu_Rollover,40,440,1
If mouseclick() = 1
Sync
End
EndIf
EndIf
`Bottom left text
ink rgb(255,255,255),rgb(255,255,255)
text 0,screen height() - 30, "Build 0.05"
text 0,screen height() - 15, "Music By Kevin Macleod"
ENDFUNCTION
Function SetupMainMenu()
MySQL_Init
ENDFUNCTION
`=====================================================================================================
`= =
`= =
`= Lobby =
`= =
`= =
`=====================================================================================================
Function Lobby()
if (currentStartTime<=0)
textToHoldStartButtonText$ = "Starting Game!"
EndIf
If (currentStartTime > 0)
textToHoldStartButtonText$ = "Starting game in " + str$(currentStartTime) + " seconds"
EndIf
If (currentStartTime = -1)
textToHoldStartButtonText$ = ""
EndIf
`Check for create lobby sprites
if sprite exist(1)
DELETE SPRITE 1
EndIf
If sprite exist(2)
DELETE SPRITE 2
EndIf
`Print background
paste image Image_Lobby_Back,0,0
STOP MUSIC Sound_Dangerous
`Loop lobby music
if currentStartTime > 0 or currentStartTime = -1
loop music Sound_PrivateReflection
EndIf
if net connected()
if Setup_LobbyGUI = 0
Setup_LobbyGUIFunc()
Setup_LobbyGUI = 1
ENDIF
For s = 1 to MAX_CONNECTIONS
If usersConnected$(s).UserName$ = UserName$
If usersConnected$(s).IsHost <> 1
`Show disabled start button because they arent host
paste image Image_Lobby_Start_Disabled,687,606,1
ink rgb(255,255,255),rgb(255,255,255)
text 687,627,textToHoldStartButtonText$
else
If currentStartTime >= 0
paste image Image_Lobby_Start_Disabled,687,606,1
EndIf
`They are host, regular mouseover button
ink rgb(255,255,255),rgb(255,255,255)
text 687,627,textToHoldStartButtonText$
`Start Button
If mousex() >= 693 and mousex() <= 845 and mousey() >= 614 and mousey() <= 648 and currentStartTime = -1
paste image Image_Lobby_Start_MouseOver,687,606,1
If mouseclick() = 1
net put byte MESSAGE_START_GAME_TIMER
net send
EndIf
EndIf
`=======================
EndIf
EndIf
NEXT s
`Exit Button
If mousex() >= 554 and mousex() <= 645 and mousey() >= 55 and mousey() <= 78
paste image Image_Lobby_Exit_MouseOver,547,47,1
If mouseclick() = 1
Setup_LobbyGUI = 0
Setup_CreateJoinLobbyPage1 = 0
Setup_CreateLobbyPage1 = 0
Delete Window ChatTextBox
Delete Window SendChatText
Delete Window ChatLobbyMessageBox
`DISCONNECT USER FROM SERVER
Net Disconnect
`Return to main menu
clickStartGame = 0
stop music Sound_PrivateReflection
`Close server program if the client name matches the iteration name and the id is 1
For x = 1 to MAX_CONNECTIONS
If usersConnected$(x).UserName$ = UserName$ and usersConnected$(x).ID = 1
`End the server
execute file "taskkill.exe", "/F /IM DesolationServer.exe", ""
EndIf
`Delete the team selection combo boxes
DELETE WINDOW arrLobbyTeamSelection(i).ID
NEXT x
EndIf
EndIf
`=======================
ink rgb(0,0,0),rgb(0,0,0)
text 230,60,ServerName$
`Print user names to screen in lobby
For i = 1 to MAX_CONNECTIONS
INK RGB(255,255,255),rgb(255,255,255)
text 135,155+((i*30)+15) , str$(i) + ")" + usersConnected$(i).UserName$
NEXT i
`Send button clicked
if (button clicked(SendChatText)) and window get text(ChatTextBox) <> ""
`Send byte and message
net put byte MESSAGE_LOBBY_CHAT
strs$ = UserName$ + ": " + window get text(ChatTextBox)
net put string strs$
net send
`Set textbox text to nothing
window set text ChatTextBox, ""
EndIf
`Disable team selection boxes that dont belong to the client
for k = 1 to MAX_CONNECTIONS
`If the username of current player is not blank
If usersConnected$(k).UserName$ <> ""
`If the current username = the username of the client
If usersConnected$(k).UserName$ = UserName$
`loop through the comboboxes
For s = 1 to array count(arrLobbyTeamSelection())
`If the players ID does not equal the same id of the combobox, disable it
If arrLobbyTeamSelection(s).ID > 0
if usersConnected$(k).ID <> arrLobbyTeamSelection(s).correspondingPlayerID
DISABLE WINDOW arrLobbyTeamSelection(s).ID
EndIf
EndIf
Next s
EndIf
EndIf
NEXT k
remstart
handle=get modified control()
c_event = get modified control event()
if handle > 0
if (c_event = 1)
for k = 1 to MAX_CONNECTIONS
`1 = comboxbox selection changed
`User's team = combobox selection
`If the handle matches the combobox that matches the player
If handle = arrLobbyTeamSelection(k).ID
end
usersConnected$(arrLobbyTeamSelection(k).correspondingPlayerID).Team$ = combobox get selected item text (handle)
EndIf
`Send the string to the server
selected_item$ = combobox get selected item text(handle)
net put byte MESSAGE_TEAM_SELECTION_CHANGED
net put int arrLobbyTeamSelection(k).correspondingPlayerID
net put string selected_item$
net send
Next k
EndIf
EndIf
remend
`If net connected
Endif
if not net connected()
`lost connection
PopupMessage((screen width() - 300)/2, (screen height() - 300)/2, 300, 300, "Lost connection. . .", rgb(128,128,128), rgb(0,0,0))
wait 5000
cls
Delete Window ChatTextBox
Delete Window SendChatText
Delete Window ChatLobbyMessageBox
DELETE WINDOW arrLobbyTeamSelection(1).ID
DELETE WINDOW arrLobbyTeamSelection(2).ID
DELETE WINDOW arrLobbyTeamSelection(3).ID
DELETE WINDOW arrLobbyTeamSelection(4).ID
Stop Music Sound_PrivateReflection
clickStartGame = 0
Setup_LobbyGUI = 0
ENDIF
Sync
ENDFUNCTION
Function Setup_LobbyGUIFunc()
totalLobbyChatMessages = 0
dbpro_w=get dbpro window() : set main window dbpro_w
ChatTextBox=make editbox(93,650,450,20,ES_MULTILINE||WS_VSCROLL,dbpro_w)
SendChatText = make button(550,650,75,20,"Send",dbpro_w)
ChatLobbyMessageBox=make editbox(93,563,525,80,ES_MULTILINE||WS_VSCROLL||ES_READONLY,dbpro_w)
For i = 1 to MAX_CONNECTIONS
arrLobbyTeamSelection(i).ID=make combobox(436,155+((i*30)+15),170,70,CBS_AUTOHSCROLL||CBS_DROPDOWN,dbpro_w)
arrLobbyTeamSelection(i).correspondingPlayerID = i
COMBOBOX ADD STRING arrLobbyTeamSelection(i).ID,"United People's Army"
COMBOBOX ADD STRING arrLobbyTeamSelection(i).ID,"Highbourne"
NEXT i
`Set time to game start to -1
currentStartTime = -1
ENDFUNCTION
`=====================================================================================================
`= =
`= =
`= Create Lobby =
`= =
`= =
`=====================================================================================================
Function CreateLobbyPage()
cls
if Setup_CreateLobbyPage1 <> 1
Setup_CreateLobbyPage()
Image_Create_Lobby_UP_Fade_Alpha = 255
Image_Create_Lobby_HB_Fade_Alpha = 0
Setup_CreateLobbyPage1 = 1
ENDIF
paste image Image_Create_Lobby_Background,0,0
sprite 1,560,20, Image_Create_Lobby_UP_Fade
sprite 2,560, 410, Image_Create_Lobby_HB_Fade
set sprite alpha 1, Image_Create_Lobby_UP_Fade_Alpha
set sprite alpha 2, Image_Create_Lobby_HB_Fade_Alpha
`UP Logo
if Image_Create_Lobby_UP_Fade_Init_FadeOut = 1
if Image_Create_Lobby_UP_Fade_Alpha = 0
Image_Create_Lobby_UP_Fade_Init_FadeOut = 0
else
dec Image_Create_Lobby_UP_Fade_Alpha
set sprite alpha 1,Image_Create_Lobby_UP_Fade_Alpha
EndIf
Endif
if Image_Create_Lobby_UP_Fade_Init_FadeOut = 0
if Image_Create_Lobby_UP_Fade_Alpha = 255
Image_Create_Lobby_UP_Fade_Init_FadeOut = 1
else
inc Image_Create_Lobby_UP_Fade_Alpha
set sprite alpha 1,Image_Create_Lobby_UP_Fade_Alpha
EndIf
EndIf
`HB Logo
if Image_Create_Lobby_HB_Fade_Init_FadeOut = 1
if Image_Create_Lobby_HB_Fade_Alpha = 0
Image_Create_Lobby_HB_Fade_Init_FadeOut = 0
else
dec Image_Create_Lobby_HB_Fade_Alpha
set sprite alpha 2,Image_Create_Lobby_HB_Fade_Alpha
EndIf
Endif
if Image_Create_Lobby_HB_Fade_Init_FadeOut = 0
if Image_Create_Lobby_HB_Fade_Alpha = 255
Image_Create_Lobby_HB_Fade_Init_FadeOut = 1
else
inc Image_Create_Lobby_HB_Fade_Alpha
set sprite alpha 2,Image_Create_Lobby_HB_Fade_Alpha
EndIf
EndIf
IF mouseclick() = 0
resetMouse = 0
ENDIF
If mousex() >= 111 and mousex() <= 215 and mousey() >= 640 and mousey() <= 670
paste image Image_Create_Lobby_Accept_Mouseover,111,640,1
If mouseclick() = 1 and resetMouse = 0
resetMouse = 1
ServerName$ = WINDOW GET TEXT(ServerNameTextBox)
PassWord$ = WINDOW GET TEXT(PasswordTextBox)
EXECUTE FILE "DesolationServer.exe",ServerName$ + ";" + PassWord$,"E:\DarkBasic\Projects\DesolationServer",0
`For Builds
`execute file "DesolationServer.exe",ServerName$ + ";" + PassWord$,""
stop music Sound_PrivateReflection
wait 3500
if sprite exist(1)
DELETE SPRITE 1
EndIf
If sprite exist(2)
DELETE SPRITE 2
EndIf
`Connect to localserver
Input "Name: ", UserName$
net connect "localhost"
EndIf
EndIf
If mousex() >= 252 and mousex() <= 357 and mousey() >= 640 and mousey() <= 670
paste image Image_Create_Lobby_Cancel_Mouseover,253,640,1
If mouseclick() = 1 and resetMouse = 0
resetMouse = 1
if sprite exist(1)
DELETE SPRITE 1
EndIf
If sprite exist(2)
DELETE SPRITE 2
EndIf
cls
clickStartGame = 0
Setup_CreateLobbyPage1 = 0
Delete Window ServerNameTextBox
Delete Window PasswordTextBox
Delete Window GameTypeComboBox
Delete Window MapTypeComboBox
EndIf
EndIf
`HOW TO DO:
remstart
after they input all the server information
they hit start server
it executes the server.exe with commandline arguments
and the server takes those arguments and puts them in the correct spot
start the server
remend
ENDFUNCTION
Function Setup_CreateLobbyPage()
Setup_CreateLobbyPage1 = 0
dbpro_w=get dbpro window() : set main window dbpro_w
ServerNameTextBox=make editbox(162,205,220,20,0,dbpro_w)
GameTypeComboBox=make combobox(162,295,140,100,CBS_AUTOHSCROLL||CBS_DROPDOWN,dbpro_w)
combobox set item height GameTypeComboBox,25
for t=0 to 10 : combobox insert string GameTypeComboBox,"Game Type: "+str$(t),t : next t
MapTypeComboBox=make combobox(162,340,140,100,CBS_AUTOHSCROLL||CBS_DROPDOWN,dbpro_w)
combobox set item height MapTypeComboBox,25
for t=0 to 10 : combobox insert string MapTypeComboBox,"Map: "+str$(t),t : next t
PasswordTextBox=make editbox(162,252,220,20,0,dbpro_w)
ENDFUNCTION
`=====================================================================================================
`= =
`= =
`= Join Lobby =
`= =
`= =
`=====================================================================================================
Function JoinLobby()
cls
If Setup_CreateJoinLobbyPage1 <> 1
Setup_JoinLobbyPage()
Image_Create_Lobby_UP_Fade_Alpha = 255
Image_Create_Lobby_HB_Fade_Alpha = 0
Setup_CreateJoinLobbyPage1 = 1
ENDIF
PASTE IMAGE Image_Join_Lobby_Backround,0,0
sprite 1,560,20, Image_Create_Lobby_UP_Fade
sprite 2,560, 410, Image_Create_Lobby_HB_Fade
set sprite alpha 1, Image_Create_Lobby_UP_Fade_Alpha
set sprite alpha 2, Image_Create_Lobby_HB_Fade_Alpha
`UP Logo
if Image_Create_Lobby_UP_Fade_Init_FadeOut = 1
if Image_Create_Lobby_UP_Fade_Alpha = 0
Image_Create_Lobby_UP_Fade_Init_FadeOut = 0
else
dec Image_Create_Lobby_UP_Fade_Alpha
set sprite alpha 1,Image_Create_Lobby_UP_Fade_Alpha
EndIf
Endif
if Image_Create_Lobby_UP_Fade_Init_FadeOut = 0
if Image_Create_Lobby_UP_Fade_Alpha = 255
Image_Create_Lobby_UP_Fade_Init_FadeOut = 1
else
inc Image_Create_Lobby_UP_Fade_Alpha
set sprite alpha 1,Image_Create_Lobby_UP_Fade_Alpha
EndIf
EndIf
`HB Logo
if Image_Create_Lobby_HB_Fade_Init_FadeOut = 1
if Image_Create_Lobby_HB_Fade_Alpha = 0
Image_Create_Lobby_HB_Fade_Init_FadeOut = 0
else
dec Image_Create_Lobby_HB_Fade_Alpha
set sprite alpha 2,Image_Create_Lobby_HB_Fade_Alpha
EndIf
Endif
if Image_Create_Lobby_HB_Fade_Init_FadeOut = 0
if Image_Create_Lobby_HB_Fade_Alpha = 255
Image_Create_Lobby_HB_Fade_Init_FadeOut = 1
else
inc Image_Create_Lobby_HB_Fade_Alpha
set sprite alpha 2,Image_Create_Lobby_HB_Fade_Alpha
EndIf
EndIf
IF mouseclick() = 0
resetMouse = 0
ENDIF
If mousex() >= 111 and mousex() <= 215 and mousey() >= 640 and mousey() <= 670
paste image Image_Create_Lobby_Accept_Mouseover,111,640,1
If mouseclick() = 1
writeln log "Clicked on accept button"
resetMouse = 1
`Accept, try connecting to the server
if sprite exist(1)
DELETE SPRITE 1
EndIf
If sprite exist(2)
DELETE SPRITE 2
EndIf
ink rgb(255,255,255),rgb(255,255,255)
Input "Name: ", UserName$
writeln log "Got input - name"
ServerIp$ = WINDOW GET TEXT(IPTextBox)
PassWordFromJoinLobby$ = WINDOW GET TEXT(PasswordJoinLobbyTextBox)
net connect ServerIp$
writeln log "Connected to server"
DELETE WINDOW IPTextBox
DELETE WINDOW PasswordJoinLobbyTextBox
writeln log "Deleted textboxes"
EndIf
EndIf
If mousex() >= 252 and mousex() <= 357 and mousey() >= 640 and mousey() <= 670
paste image Image_Create_Lobby_Cancel_Mouseover,253,640,1
If mouseclick() = 1
`Cancel
resetMouse = 1
clickStartGame = 0
Setup_CreateJoinLobbyPage1 = 0
DELETE WINDOW IPTextBox
DELETE WINDOW PasswordJoinLobbyTextBox
cls
EndIf
EndIf
ENDFUNCTION
Function Setup_JoinLobbyPage()
Setup_CreateJoinLobbyPage1 = 0
dbpro_w=get dbpro window() : set main window dbpro_w
IPTextBox=make editbox(162,205,220,20,0,dbpro_w)
PasswordJoinLobbyTextBox=make editbox(162,252,220,20,0,dbpro_w)
ENDFUNCTION
`=====================================================================================================
`= =
`= =
`= Settings Page =
`= =
`= =
`=====================================================================================================
Function SettingsPage()
cls
PASTE IMAGE Image_Main_Settings_Page,0,0
text 0,0,str$(mousex())
text 0,15,str$(mousey())
ENDFUNCTION
`=====================================================================================================
`= =
`= =
`= Logos at Beginning =
`= =
`= =
`=====================================================================================================
Function PreMainMenu()
if Setup_PreMainMenu = 0
load animation "MEDIA\Graphics\premainmenu\SilverIndy.wmv",1
play animation to image 1,Image_PreMenu_Animation,0,0,1024,768
Setup_PreMainMenu = 1
EndIf
paste image Image_PreMenu_Animation,0,0
if animation playing(1) = 0
`Animation played
clickStartGame = 0
Setup_PreMainMenu = 0
delete animation 1
EndIf
Sync
ENDFUNCTION
`=====================================================================================================
`= =
`= =
`= Load the Media =
`= =
`= =
`=====================================================================================================
Function LoadMedia()
Sound_PrivateReflection = 1
Sound_Dangerous = 2
Image_Lobby_Back = 1
Image_Main_Menu_Background = 2
Image_Create_Lobby_Basic = 3
Image_Join_Lobby_Basic = 4
Image_Settings_Main_Menu = 5
Image_Exit_Game_Main_Menu = 6
Image_Create_Lobby_Basic_Rollover = 7
Image_Join_Lobby_Basic_Rollover = 8
Image_Settings_Main_Menu_Rollover = 9
Image_Exit_Game_Main_Menu_Rollover = 10
Image_Lobby_Exit_MouseOver = 11
Image_Lobby_Start_MouseOver = 12
Image_Lobby_Start_Disabled = 13
Image_Create_Lobby_Background = 14
Image_Create_Lobby_Accept_Mouseover = 15
Image_Create_Lobby_Cancel_Mouseover = 16
Image_Create_Lobby_UP_Fade = 17
Image_Create_Lobby_HB_Fade = 18
Image_Join_Lobby_Backround = 19
Image_Main_Settings_Page = 20
load music "MEDIA\Music\Private Reflection.mp3",Sound_PrivateReflection
load music "MEDIA\Music\Shores.mp3",Sound_Dangerous
load image "MEDIA\Graphics\lobby\lobbybackground.jpg",Image_Lobby_Back
load image "MEDIA\Graphics\menu_bg.jpg",Image_Main_Menu_Background
load image "MEDIA\Graphics\create1.png",Image_Create_Lobby_Basic,1
load image "MEDIA\Graphics\join1.png",Image_Join_Lobby_Basic,1
load image "MEDIA\Graphics\settings1.png",Image_Settings_Main_Menu,1
load image "MEDIA\Graphics\exit1.png",Image_Exit_Game_Main_Menu,1
load image "MEDIA\Graphics\create2.png",Image_Create_Lobby_Basic_Rollover,1
load image "MEDIA\Graphics\join2.png",Image_Join_Lobby_Basic_Rollover,1
load image "MEDIA\Graphics\settings2.png",Image_Settings_Main_Menu_Rollover,1
load image "MEDIA\Graphics\exit2.png",Image_Exit_Game_Main_Menu_Rollover,1
load image "MEDIA\Graphics\lobby\exit2b.png",Image_Lobby_Exit_MouseOver,1
load image "MEDIA\Graphics\lobby\start1b.png",Image_Lobby_Start_MouseOver,1
load image "MEDIA\Graphics\lobby\start1bdisabled.png",Image_Lobby_Start_Disabled,1
load image "MEDIA\Graphics\clobby\clobbackground.jpg",Image_Create_Lobby_Background,1
load image "MEDIA\Graphics\clobby\accept2.jpg",Image_Create_Lobby_Accept_Mouseover,1
load image "MEDIA\Graphics\clobby\cancel2.jpg",Image_Create_Lobby_Cancel_Mouseover,1
load image "MEDIA\Graphics\clobby\UPswitch.png",Image_Create_Lobby_UP_Fade,1
load image "MEDIA\Graphics\clobby\hbpng.png",Image_Create_Lobby_HB_Fade,1
load image "MEDIA\Graphics\jlobby\jlobbybackground.jpg",Image_Join_Lobby_Backround
LOAD IMAGE "MEDIA\Graphics\settings\settingsbg.jpg",Image_Main_Settings_Page
ENDFUNCTION
Function LOAD_GAME_MEDIA()
ENDFUNCTION
Function FreeObject()
Repeat
Inc i
Until Object Exist(i) = 0
Endfunction i
Function FreeImage()
Repeat
Inc i
Until Image Exist(i) = 0
Endfunction i
module_GUI.dba
Rem ***** Included Source File *****
Function PopupMessage(x as integer, y as integer, height as integer, width as integer, message as string, colorBox as DWORD, colorText as DWORD)
box x,y,x+width,y+height,colorBox
ink colorText,colorText
text x + (width/2) - (text width(message)/2), y + (height/2) - (text height(message)/2), message
EndFunction
function scrolltext(y#,lx#,rx#,text$,s#,spd#,tsize,tfont$)
set text size tsize
set text font tfont$
x1#=rx#
x1#=x1#-s#
for ch#=1.0 to len(text$)
if x1#<=rx#
if x1#>lx#
text x1#,y#,mid$(text$,ch#)
endif
endif
x1#=x1#+text width(mid$(text$,ch#))
next ch#
if x1#<=lx#
s#=0
endif
s#=s#+spd#
endfunction s#
module_LoadGameMedia.dba
GLOBAL Image_Selection_Circle = 21
Function LoadGameMedia()
Image_Selection_Circle = 21
LOAD IMAGE "MEDIA\Graphics\game\units\selectionu.png",Image_Selection_Circle,1
ENDFUNCTION
SERVER
DesolationServer.dba
#CONSTANT MAX_CONNECTIONS 2
#CONSTANT MESSAGE_ID_PLAYERJOINED 3
#CONSTANT MESSAGE_ID_PLAYERQUIT 4
#CONSTANT MESSAGE_GET_NAME 5
`#CONSTANT MESSAGE_HOST_START_GAME_BUTTON 6
#CONSTANT MESSAGE_LOBBY_CHAT 7
#CONSTANT MESSAGE_START_GAME_TIMER 8
#CONSTANT MESSAGE_TEAM_SELECTION_CHANGED 9
#CONSTANT MESSAGE_PING 10
Sync On
Sync Rate 60
GLOBAL ServerName$ = "Dave's Test Desolation Server"
GLOBAL PassWord$ = "test"
totalConnections = 0
if NOT net host(MAX_CONNECTIONS)
error$ = net get error()
Print error$
else
text 0,0,"Ready for connections."
ENDIF
Type Player
ID as integer
UserName$ as String
Team$ as String
IsHost as Integer `1 = yes, 2 = no
EndType
Dim usersConnected$(2) as Player
usersConnected$(1).ID = -1
usersConnected$(1).UserName$ = ""
usersConnected$(1).Team$ = ""
usersConnected$(1).IsHost = -1
usersConnected$(2).ID = -1
usersConnected$(2).UserName$ = ""
usersConnected$(2).Team$ = ""
usersConnected$(2).IsHost = -1
GLOBAL team$
Do
`Get command line args
commandLineArgs$ = cl$()
Explode(";",commandLineArgs$)
cls
Print "Server Started: "; ServerName$
Print "Total Connections: "; totalConnections
Print "Password: "; PassWord$
`player joined
connection = net player joined()
while connection > 0
`Send First Byte
Net Put Byte MESSAGE_ID_PLAYERJOINED
`Send Servername to buffer
Net Put String ServerName$
`Put the password on the buffer
NET PUT String PassWord$
totalConnections = totalConnections + 1
net put byte totalConnections
`Find a free spot to put in user
For x = 1 to totalConnections
If usersConnected$(x).ID < 1 and usersConnected$(x).UserName$ = ""
usersConnected$(x).ID = connection
net put byte x `Array Place
net put byte connection`ID Number
If usersConnected$(x).ID = 1
`Player is host
usersConnected$(x).IsHost = 1
EndIf
EndIf
Next x
`Send data to all the users
net send all
`Reset connection variable
connection = net player joined()
endwhile
`player leaves
playerleft = net player left()
while playerleft > 0
For x = 1 to MAX_CONNECTIONS
If usersConnected$(x).ID = playerleft
usersConnected$(x).UserName$ = ""
usersConnected$(x).ID = -1
`Send first byte
net put byte MESSAGE_ID_PLAYERQUIT
`Send the byte that is the player id that left
net put byte x
`Send message to all clients connected
net send all
`Change total connections
totalConnections = totalConnections - 1
`If player is host, kick everyone
If usersConnected$(x).IsHost = 1
for s = 1 to MAX_CONNECTIONS
Net Kick usersConnected$(s).ID
NEXT s
EndIf
`Resest playerleft
playerleft = net player left()
Endif
Next x
endwhile
`============================User Names===========================================
Print "Users Connected: "
while net get message()
select net get byte()
case MESSAGE_GET_NAME
UserConnected$ = net get string()
arrayPlace = net get byte()
playerID = net get byte()
usersConnected$(arrayPlace).UserName$ = UserConnected$
`select case statment with the first data byte received to determine what to do
`Send name of player to all clients for use in lobby
net put byte MESSAGE_GET_NAME
For i = 1 to totalConnections
net put string usersConnected$(i).UserName$
NEXT i
net send all
endcase
case MESSAGE_LOBBY_CHAT
`Chat from the lobby
chatstr$ = net get string()
if chatstr$ <> ""
net put byte MESSAGE_LOBBY_CHAT
net put string chatstr$
net send all
EndIf
endcase
case MESSAGE_START_GAME_TIMER
`timer tick
loopcount = 0
countstart = 5 `seconds
starttime = timer()
count = countstart-((timer() - starttime)/1000)
doStartGame = 1
while loopcount = 0
cls
if count > 0 and doStartGame = 1
count = countstart-((timer() - starttime)/1000)
NET PUT BYTE MESSAGE_START_GAME_TIMER
NET PUT INT count
NET SEND ALL
PRINT "Game Starting In: " ; str$(count)
else
PRINT "Starting Game!"
loopcount = 1
endif
endwhile
endcase
case MESSAGE_TEAM_SELECTION_CHANGED
`In lobby, team selection changed in combobox
arrayplace = net get int()
team$ = net get string()
usersConnected$(arrayplace).Team$ = team$
`Resend data to all clients
net put byte MESSAGE_TEAM_SELECTION_CHANGED
net put int arrayplace
net put string team$
net send all
endcase
CASE MESSAGE_PING
`Send ping packet back to client
username$ = NET GET STRING()
time = NET GET INT()
NET PUT BYTE MESSAGE_PING
NET PUT STRING username$
NET PUT INT time
For x = 1 to MAX_CONNECTIONS
If usersConnected$(x).Username$ = username$
NET SEND usersConnected$(x).ID
ENDIF
Next x
endcase
endselect
endwhile
For i = 1 to MAX_CONNECTIONS
Print i;")";usersConnected$(i).UserName$;""
NEXT i
print "usersConnected$(1).Team$: ";usersConnected$(1).Team$
print "usersConnected$(2).Team$: ";usersConnected$(2).Team$
print "team$: ";team$
`===============================================================================================
Sync
LOOP
Function Explode(Split$,Fullstring$)
for k = 1 to len(FullString$)
if mid$(FullString$,k) = Split$
ServerName$ = left$(Fullstring$,k - 1)
PassWord$ = right$(Fullstring$,len(Fullstring$)-k)
k = len(Fullstring$)
endif
next k
endfunction
If anyone can please please please attempt to help, it would be greatly appreciated. These random crashes stopped progress on this.