Growlith1223 Posted June 5, 2015 Author Share Posted June 5, 2015 In normal versions of Eclipse(for those who have no idea what im talking about, the engine uses GetTickCount directly instead of checking to see if the value is = to or < than 0) the Tick value can go lower than 0 and cause the engine to crash from Longs not being able to use negative values.To fix this it's rather simple, and I'll show you how! :DOK, so first thing you should do is decide to use timeGetTime instead because it will last longer, and its more accurate.the next thing you should do is go into where you have your server/client loop and copy/paste this in:```Public Function GetTick() As Long   Const MAX_INT As Long = 2147483647   If GetTickCount < 0 Then       GetTick = MAX_INT + GetTickCount   Else   GetTick = GetTickCount   End IfEnd Function```after that, go into said loop and find where it says Tick = GetTickCount. and change that GetTickCount to just GetTick!you're for the most part done, you will have to find all the areas that are calling GetTickCount and change it to that GetTick function! this will ensure the value is ALWAYS a positive value to ensure that it won't error after a long host(keeping the server up for days would eventually crash it due to said negative value).Anywho, lemme know if you get confused by this tutorial and i'll help you in any way I can! Link to comment Share on other sites More sharing options...
YourBestNightmare Posted June 5, 2015 Share Posted June 5, 2015 Constant in function. I have not touched VB6 for years, but I am sure you will go to programmer hell for doing this. Link to comment Share on other sites More sharing options...
abhi2011 Posted June 5, 2015 Share Posted June 5, 2015 But then again, VB6 programmers already are in hell and have survived it compared to people who program in other languages. (I'm talking about instability of VB6 and how it's comparatively featureless) Link to comment Share on other sites More sharing options...
Growlith1223 Posted June 5, 2015 Author Share Posted June 5, 2015 @'YourBestNightmare':> Constant in function. I have not touched VB6 for years, but I am sure you will go to programmer hell for doing this.I don't see any problem here, it's only being used within that sub specifically not to mention that's like dims are horrible in subs, wtf are you on about. Link to comment Share on other sites More sharing options...
YourBestNightmare Posted June 5, 2015 Share Posted June 5, 2015 @'Growlith1223':> @'YourBestNightmare':> > > Constant in function. I have not touched VB6 for years, but I am sure you will go to programmer hell for doing this.> > I don't see any problem here, it's only being used within that sub specifically not to mention that's like dims are horrible in subs, wtf are you on about.You want to defend your code? Okay, leaving this thread, I have nothing to talk about with you then. Link to comment Share on other sites More sharing options...
Growlith1223 Posted June 5, 2015 Author Share Posted June 5, 2015 @'YourBestNightmare':> @'Growlith1223':> > > @'YourBestNightmare':> > > > > Constant in function. I have not touched VB6 for years, but I am sure you will go to programmer hell for doing this.> > > > I don't see any problem here, it's only being used within that sub specifically not to mention that's like dims are horrible in subs, wtf are you on about.> > You want to defend your code? Okay, leaving this thread, I have nothing to talk about with you then.you're complaining over nothing then leave over nothing, why were you here to begin with? Link to comment Share on other sites More sharing options...
Joyce Posted June 5, 2015 Share Posted June 5, 2015 I'd put this in modConstants, honestly.```Const MAX_INT As Long = 2147483647```Or replace it with```Dim MAX_INT as Long = 2147483647```It's not a particularly good idea or best practice to declare constants inside a method, seeing how they can be run several times. A constant should only ever be declared ONCE during your program's flow. Redefining a constant a couple hundred+ times per second is not a good idea, I'm surprised VB6 even lets you do that. Link to comment Share on other sites More sharing options...
Growlith1223 Posted June 5, 2015 Author Share Posted June 5, 2015 I've tested this and there was literally no change in performance nor cpu/memory usage. I done Const MAX_INT within the method because there's no point in making it a global constant since this is the only thing using it. There was literally no ms change in doing what I've done so I went with it. god damn I finally release a tutorial in nearly 3 years and nothing but complaints. Link to comment Share on other sites More sharing options...
Joyce Posted June 5, 2015 Share Posted June 5, 2015 It's unlikely to make a difference in speed, seeing how it's declared only within the scope of your method. Doesn't mean you should not be able to take criticism on poor coding practices and improve though. Imagine if everyone just did their own thing "because it works right?" in critical software. There's a reason coding standards were made and why best practices exist.Criticism is not complaining. Link to comment Share on other sites More sharing options...
Growlith1223 Posted June 5, 2015 Author Share Posted June 5, 2015 So what you're essentially saying is using my own standard is bad…? ok, fine this is my last tutorial lol.EDIT: also I know complaints was the wrong word. either way, if I can't use my own standard then there's no point in posting tutorials anymore, I shouldn't have to follow this "Coding standard" instead of my own. >_> Link to comment Share on other sites More sharing options...
Justin Knight Posted February 7, 2016 Share Posted February 7, 2016 Thanks Growlith1223, my server would crash requiring a full reboot once a week. This seems to have fixed the issue though! Link to comment Share on other sites More sharing options...
Growlith1223 Posted February 7, 2016 Author Share Posted February 7, 2016 No problem! this has been an issue with the engine for years, i discovered this fix for it, basically this will convert the number to a positive, therefore will always be a positive value. Link to comment Share on other sites More sharing options...
Lavos Posted February 7, 2016 Share Posted February 7, 2016 Thanks for sharing this Growlith, it looks like knightkid had me convinced. I'm going to give this a try now. Link to comment Share on other sites More sharing options...
Growlith1223 Posted February 7, 2016 Author Share Posted February 7, 2016 from my testing of having my comp up for about 1-2 months, any engine i have thrown this into has never crashed, there might be a mishap with it resetting back to 0 but it's fairly easy to fix with a small skip of one cycle and to fix that desync, you would just need to reposition everyone Link to comment Share on other sites More sharing options...
Helladen Posted February 8, 2016 Share Posted February 8, 2016 VB6 was good for awhile, .NET has finally matured and time to move on. :P Even though the IDE sucked, the speed and performance of VB6 was better for many years after Microsoft abandoned it.Can't you just use a .DLL like Thomas coded in a new way to handle the tick count using timeGetTime which utilizes a new method of keeping track of the time, rather than using the plain old GetTickCount. This is also better and harder to hack I have noticed. Link to comment Share on other sites More sharing options...
Growlith1223 Posted February 8, 2016 Author Share Posted February 8, 2016 you do realize that even .NET Environment.TickCount also has the issue of going negative?also if you're using getTickCount OR timeGetTime in .net then you need to learn how to code in .netboth getTickCount and timeGetTime have the issue of roll-backing into a negative value, ere-go crashing everything. Link to comment Share on other sites More sharing options...
BeNjO Posted February 8, 2016 Share Posted February 8, 2016 @'Helladen':> VB6 was good for awhile, .NET has finally matured and time to move on. :P Even though the IDE sucked, the speed and performance of VB6 was better for many years after Microsoft abandoned it.> > Can't you just use a .DLL like Thomas coded in a new way to handle the tick count using timeGetTime which utilizes a new method of keeping track of the time, rather than using the plain old GetTickCount. This is also better and harder to hack I have noticed.But yet still continues to use VB6\. You said in another thread that was deleted about moving on and going 3D and within about 2 hours of posting it you released a new update for mirage source on hitspark. Link to comment Share on other sites More sharing options...
Helladen Posted February 8, 2016 Share Posted February 8, 2016 @'BeNjO':> But yet still continues to use VB6\. You said in another thread that was deleted about moving on and going 3D and within about 2 hours of posting it you released a new update for mirage source on hitspark.I am using Visual Basic 6 for now. The updater I made for Nin Online is in .NET - I can write in .NET and OO too. I just have a lot of work that I would throw away if I rewrote the engine in a new language. I am utilizing my resources effectively here, not restarting when there is no need. But yes, I am moving tools and such over to .NET and getting more experienced in the language. Link to comment Share on other sites More sharing options...
abhi2011 Posted February 8, 2016 Share Posted February 8, 2016 @'Growlith1223':> you do realize that even .NET Environment.TickCount also has the issue of going negative?> > also if you're using getTickCount OR timeGetTime in .net then you need to learn how to code in .net> both getTickCount and timeGetTime have the issue of roll-backing into a negative value, ere-go crashing everything.You can use unsigned ints or go for a long for the API calls. And, Enviorment.TickCount's MSDN page provides a way of converting the negative to a >0 value. Link to comment Share on other sites More sharing options...
Growlith1223 Posted February 9, 2016 Author Share Posted February 9, 2016 I know that MSDN has a fix for it in .NET, this is what i've come up with for VB6.and that doesn't change the fact that it still rolls back to a negative value, hence why i made this tutorial for a VB6 side of TickCount. ._. Link to comment Share on other sites More sharing options...
Lief1606 Posted September 30, 2016 Share Posted September 30, 2016 I've compiled the server without errors, but when I try to compile the client it gives me that error:>! ![](http://i.imgur.com/6Qxu7Pe.png)(Image link: http://i.imgur.com/6Qxu7Pe.png )I did everything you said>! By the way, I'm using Skywyre v10. Link to comment Share on other sites More sharing options...
BeNjO Posted September 30, 2016 Share Posted September 30, 2016 you have 2 "GetTick" subs in the client source. Remove both and add the one from the tutorial again to make sure you "keep" the right one :). Link to comment Share on other sites More sharing options...
Lief1606 Posted September 30, 2016 Share Posted September 30, 2016 I've found a Public Declare Function GetTick Lib "kernel32" () As Long on modGeneral then I just put a ' before itThen it gave me this error:![](http://i.imgur.com/X15VpjL.png)and I added it below the line I've commented before:Public Declare Function GetTickCount Lib "kernel32" () As Longand it compiled with no errors, but is it ok to do that or it will give me another error in the future? Link to comment Share on other sites More sharing options...
Growlith1223 Posted September 30, 2016 Author Share Posted September 30, 2016 you'll want to keep that GetTickCount declare, that sub gets a system interval, the GetTick function i made checks to see if it rolled back, as after about 10 or so days, it rolls back to a very large negative value, causing crashes at that point, my getTick is like a wrapper over that value, so it ensures it is ALWAYS a positive value. Link to comment Share on other sites More sharing options...
Lavos Posted September 30, 2016 Share Posted September 30, 2016 I've tried this method and it seemed a little sluggish and clunky, i don't like it. My fps seemed to be getting its normal rate at 64 but something did not seem right on the eyes. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now