vbGore Free Online RPG Engine

Revolutionizing Visual Basic ORPG Development
It is currently Tue May 21, 2013 9:02 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Workaround for a bug ultimately causing missing graphics
PostPosted: Sun Jun 22, 2008 7:12 am 
Newbie

Joined: Sun Jun 22, 2008 6:28 am
Posts: 1
I found this bug in 1.0.14 (which is the only version I've tried so far).

From what I can see, the return value of timeGetTime() is assumed to always be positive. Since it is a DWORD value redefined as a Long in Visual BASIC, it can be negative if the uptime of the computer running the game is long enough (at least 24 days, 20 hours, 31 minutes, 23 seconds and 648 milliseconds). In various places in the code, values based on this return code are assumed never to go below zero. One thing that depends on this is a conditional test to see whether images need to be initialized, and for this reason this bug leads to graphics never being properly initialized, so most graphics isn't drawn at all (although several polygons and various text is). There may be other time-related problems as well, but since graphics are weird it's somewhat hard to tell...


Here is a quick fix to get rid of the problem (not optimal due to the extra calculations, but I believe it should work as long as you don't play for more than ~ 24 days 20 hours without quitting; after that it would depend on exactly when you started playing). I of course provide this code as is and without any warranties whatsoever. Feel free to correct any bugs I might have introduced.


First, change the "Public Declare Function" line for timeGetTime in Declares.bas to read:

Public Declare Function timeGetTimeInDll Lib "winmm.dll" Alias "timeGetTime" () As Long


Next, add the following function (dunno how to make phpBB indent so you'll have to do that on your own):

Public Function timeGetTime() As Long
Static InitialTime As Long
Static Running As Boolean
If Not Running Then
Running = True
InitialTime = timeGetTimeInDll
timeGetTime = 0
Exit Function
End If

timeGetTime = timeGetTimeInDll

On Error GoTo needadjust
timeGetTime = timeGetTime - InitialTime
Exit Function

needadjust:
On Error GoTo 0
Resume doadjust

doadjust:
timeGetTime = CLng(CDbl(timeGetTime) - CDbl(InitialTime) + 4294967296#)
End Function


Top
 Profile  
 
 Post subject: Re: Workaround for a bug ultimately causing missing graphics
PostPosted: Thu Jun 26, 2008 2:35 am 
+3 Gloves of Agility

Joined: Fri Mar 23, 2007 1:15 pm
Posts: 164
the same can be said for GetTickCount()


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group