| Mirage Source http://miragesource.net/forums/ |
|
| [Improvement] Player Update http://miragesource.net/forums/viewtopic.php?f=193&t=5450 |
Page 1 of 1 |
| Author: | Jacob [ Fri Apr 10, 2009 1:48 am ] |
| Post subject: | [Improvement] Player Update |
Currently updating vitals and saving players is all done at the same time for all players. Some code to change that. Private Type TempPlayerRec Add the following to the UDT Code: LastUpdateVitals As Long LastUpdateSave As Long modServerLoop Change your ServerLoop to the following: Code: Public Sub ServerLoop() Dim i As Long Dim x As Long Dim y As Long Dim Tick As Long Dim tmr500 As Long Dim tmr1000 As Long Dim LastUpdateMapSpawnItems As Long ServerOnline = True Do While ServerOnline Tick = GetTickCount If Tick > tmr500 Then ' Check for disconnections For i = 1 To MAX_PLAYERS If frmServer.Socket(i).State > sckConnected Then Call CloseSocket(i) End If ' Update the player If IsPlaying(i) Then OnUpdate i End If Next ' Process NPC AI UpdateNpcAI tmr500 = GetTickCount + 500 End If If Tick > tmr1000 Then ' Handle shutting down server If isShuttingDown Then Call HandleShutdown End If ' Handles closing doors For i = 1 To MAX_MAPS If Tick > TempTile(i).DoorTimer + 5000 Then For x = 0 To MAX_MAPX For y = 0 To MAX_MAPY If Map(i).Tile(x, y).Type = TILE_TYPE_KEY Then If TempTile(i).DoorOpen(x, y) = YES Then TempTile(i).DoorOpen(x, y) = NO Call SendDataToMap(i, SMapKey & SEP_CHAR & x & SEP_CHAR & y & SEP_CHAR & 0 & END_CHAR) End If End If Next Next End If Next tmr1000 = GetTickCount + 1000 End If ' Checks to spawn map items every 5 minutes - Can be tweaked If Tick > LastUpdateMapSpawnItems Then UpdateMapSpawnItems LastUpdateMapSpawnItems = GetTickCount + 300000 End If Sleep 1 DoEvents Loop End Sub modPlayer- JoinGame Add the following before "End Sub" Code: TempPlayer(Index).LastUpdateVitals = GetTickCount + 10000 TempPlayer(Index).LastUpdateSave = GetTickCount + 600000 modPlayer Add the following sub Code: ''*************************************** ' Events for updating '*************************************** Sub OnUpdate(ByVal Index As Long) Dim i As Long '***************************** '** Checks to save player ** '***************************** If GetTickCount > TempPlayer(Index).LastUpdateSave Then SavePlayer Index TempPlayer(Index).LastUpdateSave = GetTickCount + 600000 ' 10 minutes End If '************************************** '** Checks to update player vitals ** '************************************** If GetTickCount > TempPlayer(Index).LastUpdateVitals Then For i = 1 To Vitals.Vital_Count - 1 If GetPlayerVital(Index, i) <> GetPlayerMaxVital(Index, i) Then Call SetPlayerVital(Index, i, GetPlayerVital(Index, i) + GetPlayerVitalRegen(Index, i)) Call SendVital(Index, i) End If Next TempPlayer(Index).LastUpdateVitals = GetTickCount + 5000 ' 5 seconds End If End Sub So when a player logs in they are set to their own timers. This really helps in saving, not all players being saved at once. This also helps later on for more advanced features. I've added spell buffs and i use the OnUpdate sub to check if the buff duration is over. Thoughts / Comments ? I think I'll modify this for a future version of MS. (Waiting on something from DFA before I start) |
|
| Author: | Dragoons Master [ Fri Apr 10, 2009 1:54 am ] |
| Post subject: | Re: [Improvement] Player Update |
You should not make this. It's not fair. The players "backup" should be saved for everybody at the same time. |
|
| Author: | Jacob [ Fri Apr 10, 2009 2:12 am ] |
| Post subject: | Re: [Improvement] Player Update |
If you have proper error handling, saving the players at different times shouldn't matter. By proper error handling, I mean on all code it will catch and error then try to handle it. If it can't be handled it should shut down the server, in the shut down process it should save all players. |
|
| Author: | Tony [ Fri Apr 10, 2009 2:19 am ] |
| Post subject: | Re: [Improvement] Player Update |
Yeah, shouldn't saving at different times be less stressful for the server? |
|
| Author: | GIAKEN [ Fri Apr 10, 2009 2:31 am ] |
| Post subject: | Re: [Improvement] Player Update |
Items need to have their own respawn timers, too. |
|
| Author: | Labmonkey [ Fri Apr 10, 2009 3:06 am ] |
| Post subject: | Re: [Improvement] Player Update |
It would seem better to just save players when they level up. That way you never loose levels due to server crashes (the most complained about part of server crashes) |
|
| Author: | Cruzn [ Fri Apr 10, 2009 3:41 am ] |
| Post subject: | Re: [Improvement] Player Update |
Labmonkey wrote: It would seem better to just save players when they level up. That way you never loose levels due to server crashes (the most complained about part of server crashes) That's fine until you have higher level players whose levels are few and far between. By doing that, you are forcing one portion of a playerbase to log out and log back in again to force the server to save them.
|
|
| Author: | Labmonkey [ Fri Apr 10, 2009 4:06 am ] |
| Post subject: | Re: [Improvement] Player Update |
ok |
|
| Author: | Dragoons Master [ Fri Apr 10, 2009 4:24 am ] |
| Post subject: | Re: [Improvement] Player Update |
You can't be 100% sure that you can even handle every bug. Lets just say you don't have a no-break and then light goes out. IMO the server does not need to save game state every x time. I'm backing up the db every 24h, on the server restart. If a "unhandleble" error occurs just restore the last day. 24 hours is acceptable. |
|
| Author: | Asrrin29 [ Fri Apr 10, 2009 4:51 am ] |
| Post subject: | Re: [Improvement] Player Update |
Make it so that every time a character gains exp, check a random number against a predetermined chance to see if the character gets saved. decrease the predetermined chance every time the check fails (to prevent the server from "never" saving the player) and reset it once the character gets saved. This way, at most the player will lose a few kills, a couple dozen or so, but it also is not saving every character all the time. You can also have it save after every quest, every x trades, whatever. you can also include a mass player save function to run in the dead of night if you want. |
|
| Author: | Joost [ Fri Apr 10, 2009 1:32 pm ] |
| Post subject: | Re: [Improvement] Player Update |
Saving players based on whether the dice rolls 6 or not? Sounds fucked up. Instead of saving them ALL at once, or or all unique, just process the first 10% of the indexes online every minute. |
|
| Author: | Asrrin29 [ Fri Apr 10, 2009 4:08 pm ] |
| Post subject: | Re: [Improvement] Player Update |
first check, 1 in 6 chance next chance 1 in 5 next 1 in 4 next 1 in 3 next 1 in 2 next 1 in 1 Eventually the player will get saved, but not every time they gain experience, and not at the same times as other players. |
|
| Author: | GIAKEN [ Fri Apr 10, 2009 7:38 pm ] |
| Post subject: | Re: [Improvement] Player Update |
Are you thinking when you post? Saving players on a RANDOM CHANCE? Might as well tell them "You only have a chance you will keep your hard-work safe from server crashes, but eventually you will get more luckier." Please just think and shitty suggestions won't happen anymore hopefully. |
|
| Author: | Jacob [ Fri Apr 10, 2009 8:18 pm ] |
| Post subject: | Re: [Improvement] Player Update |
GIAKEN wrote: Are you thinking when you post? Saving players on a RANDOM CHANCE? Might as well tell them "You only have a chance you will keep your hard-work safe from server crashes, but eventually you will get more luckier." Please just think and shitty suggestions won't happen anymore hopefully. If you're going to provide criticism, don't be a dick about it. |
|
| Author: | Asrrin29 [ Fri Apr 10, 2009 8:31 pm ] |
| Post subject: | Re: [Improvement] Player Update |
you have a chance to lose the last 6 kills you made, or the last one, or any in between. I am not going to cry about not getting my last six kills. The only other way to make sure that no one loses any information is to save after every player change, which would cause alot of disk activity and ultimately bog down the game. Look, I'm just trying to provide a way to find a middle ground between arbitrary updates and continuous updates. if you don't like it, then show me something better. |
|
| Author: | Labmonkey [ Fri Apr 10, 2009 8:34 pm ] |
| Post subject: | Re: [Improvement] Player Update |
the method up top. |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|