• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

1156 Excellent

1 Follower

About spacecamp

  • Rank

Personal Information

  • Interests
  1. Balancing server update loop

    Previously I had the whole 'dt_sys' loop out of the loop. What was happening is that it was spending a huge amount of time trying to lock mutexes. I do have mutexes(CRITICAL_SECTION) in places such us PopCompletedParallelTask, FlushClientSendBuffer(I use IOCP for external networking) and similar. I do decrement them inside the loop after every step. /* Calculate delta time */ ct = GetTickCount(); dt = ct - g->last_update_ticks; dt_sys = ct - g->last_sys_update_ticks; while (dt_sys >= SYSTEM_STEP_SIZE) { if (dt_sys >= 500) { logMsg("System update loop has fallen behind: dt=%u", dt_sys); step_size = dt_sys; } else { step_size = SYSTEM_STEP_SIZE; } /* Update things */ dt_sys -= step_size; } /* Do similar for simulation update loop */ g->last_update_ticks = ct - dt; g->last_sys_update_ticks = ct - dt_sys; I'm using GetTickCount() indeed. I will look into QueryPerformanceCounter().
  2. Hello. I have a bizarre inconsistency in my server update loop. Below is approximately what I do: /* Calculate delta time, do other minor things */ while (dt_sys >= SYSTEM_STEP_SIZE) { /* SYSTEM_STEP_SIZE = 20ms */ /* Update sockets which are connected to other servers, swap queues for received packets, parse queue for received packets(doesn't actually parse packets but instead copies received data onto client ring buffers), update send network ring buffers for all clients, parse parallel task results */ } while (dt >= STEP_SIZE) { /* STEP_SIZE = 50ms */ /* Run game simulation */ } /* Travers client list and parse packets (with a maximum value as to how many can be parsed) */ I get very inconsistent update times for my game simulation(sometimes it's 0ms, sometimes it's 16, 60, 100 and goes all the way up to >1sec!). As you might have noticed I don't have any sleep in anywhere in my code so it ends up taking up an entire CPU core(is it a bad thing to do?). Now here's the bizarre part, when I attach a profiler (Very Sleepy CS) the inconsistency sort of disappears. I start getting update times between 0-16ms with very rare spikes. I'm honestly very confused at this point and not sure how to debug this further. Another thing worth mentioning is that I use GetTickCount to calculate delta time used in loops above.
  3. Improving persistent data consistency

    There's one last thing I'd like to ask before I delve into attempting to move onto database storage. Should I keep storing data as binary blobs or structured tables (a different table for account information, player information, item information, etc.)? Binary blobs seem simpler but I would need to serialize whole account data every time I want to make a relatively small commit like an item deletion.
  4. Improving persistent data consistency

    I've been considering using databases but am afraid of the initial workload it could bring. Using file-based storage is really nice for me when developing but using a database might be inevitable due to limitations pointed by hplus0603.   As you mentioned I don't commit anything to disk other than when I'm taking backups so I don't actually write to a guild entity file when someone joins a guild until next scheduled backup.   I will see if I can move onto using a database. My last attempt wasn't very successful but that was mainly due to me using them improperly.   This is actually something I'm not sure about. With file-based storage I feel the need to either save ALL game data at one successful attempt or none at all. Reason being, for example when 2 players trade an item, I would need to re-write 2 files. If something goes wrong after re-writing the first file I'd end up with a duplicate of same item. Which is probably another thing which could be solved automatically by moving onto a database storage.   That I believe I didn't mess up. I do take a backup to a separate folder first and then copy that backup to a dummy folder to finally swap with live server folder.
  5. Hello people. I'll start of by explaining my current persistent data model and then ask for some advice regarding it.   Currently I'm using a "single file per entity" kind of model to store persistent data. A single file for each account which includes account information, player information, item information belonging to each player, etc. Similar goes for guilds and other separate entities. I do load accounts when someone attempts to login and unload when a backup is being taken. For guilds and other similar entities, I load them and never unload.   This works fine for the most part but, when the server crashes for whatever reason I lose all data which changed since last backup. So my question is, can I adjust my system in a way that even if the server crashes I will be able to recover unsaved data?
  6. Sorry for the late reply Feint. While your project seems interesting it doesn't seem like what I'm looking for.   @Eddow, I did add you earlier today. Hopefully we can talk further tonight.
  7. Hey,  I was thinking of starting from the very start. As in creating a window using OS api(CreateWindow(Ex) for windows for ex.), creating a render context for OpenGL, etc. The word 'engine' is pretty scary so I guess I'd call it working on a set of tools to help us build a game.  Nice name by the way :)

    Just because something is done by a lot of people doesn't make it legitimate.    However, seeing as the game is dead and likely to be never used by its copyright owner, it might not be such a bad thing for someone to try to revive it considering they're willing to write their own server which is a heck load of work.
  9. I'm a self taught c/c++ programmer with a few years of non commercial experience and written a range of non commercial applications. I do have a bit of experience with OpenGL(like I have written a parser/renderer for a certain model file format and written few mini games) but lack in more advanced 3D programming topics.    I'm already working on another project which takes a good chunk of my time so I would like to take it easy with this one. Main objective in this project would be to explore 3D programming techniques and apply them to whatever game we would be working on. Needless to say that the person I am to partner up with would be free of any task and choose to contribute whenever, to whatever.    I was thinking of an abstract online rpg as the genre for the game. 'Abstract' as in world, characters, etc. to reduce the need for models. I'd be in charge of networking as it is the subject I'm most comfortable with. That said, I'm opened for better suggestions.   If you're interested, feel free to message me here.
  10.   Thanks, I'll read up on these.       You're right! After reading your answer I went back an reread the paper and it indeed mentions about a freelist for nodes. I will go ahead and read about lockfree linked lists. Thanks for the answer.
  11. I'm trying to understand and implement a lock free queue in C. However there're some parts of the whitepaper I'm reading which I'm confused about.   First, if you look at line D5, locally stored head and Q->Head are being compared. When remove, it's causing issues regarding dead memory but I cannot understand how this provides any protection as Q->Head can be modified after the comparison was made. Second, if you look at lines D4 and D19, head.ptr can(and sometimes is) be a freed pointer causing an access violation exception to be thrown.   Current implementation I have suffers from the second issue I mentioned: int dequeue(struct Queue *queue, void **data) {      struct Pointer QUEUE_ALIGN     head;      struct Pointer QUEUE_ALIGN     tail;      struct Pointer QUEUE_ALIGN     next;      struct Pointer QUEUE_ALIGN     new_ptr;        while (1)      {           head   = queue->head;           tail   = queue->tail;           next   = head.ptr->next;             if (head.ptr == queue->head.ptr && head.counter == queue->head.counter)           {                if (head.ptr == tail.ptr)                {                     if (next.ptr == 0)                     {                          return 0;                     }                     new_ptr.ptr      = next.ptr;                     new_ptr.counter  = tail.counter + 1;                     DWCAS((void*)&queue->tail, (void*)&tail, (void*)&new_ptr);                }                else                {                     *data           = next.ptr->data;                     new_ptr.ptr     = next.ptr;                     new_ptr.counter = head.counter + 1;                       if (DWCAS((void*)&queue->head, (void*)&head, (void*)&new_ptr))                     {                          break;                     }                }           }      }      free(head.ptr);      return 1; }
  12. Having trouble with view matrix and camera direction

    Much appreciated for the detailed answer. Looking at your examples, I realised I've been going at it the wrong way. Now that I've removed pitch and yaw variables and apply rotation/transformation whenever a new input is given, I no longer have the issue and all works well. Thanks!
  13. Hi. I'm having some trouble with view matrix and forward direction of the camera. With below code I get the correct forward vector so long as I'm facing towards negative z axis. But once I'm facing positive z axis (x,y) of forward starts getting incorrect. Mat4f createViewMat(Vec3f *eye, float pitch, float yaw) {              Mat4f rot = matRot4f(-pitch, -yaw, 0.f); // returns a rotation matrix              Mat4f tra = { 1.f, 0.f, 0.f, -eye->x,  // I use row-major matrices                           0.f, 1.f, 0.f, -eye->y,                           0.f, 0.f, 1.f, -eye->z,                           0.f, 0.f, 0.f, 1.f };              return matMult4m(&rot, &tra); } void updateCamera(Vec3f *eye, float pitch, float yaw, Mat4f *view_mat, Vec3f *forward) {              Mat4f rot;              Vec3f dir;              pitch = min(pitch, 90.f);              pitch = max(pitch, -90.f);              yaw = (yaw < 0.f) ? (yaw + 360.f) : ((yaw > 360.f) ? (yaw - 360.f) : yaw);              *view_mat = createViewMat(eye, pitch, yaw);              rot = matRot4f(pitch, yaw, 0.f);              dir = vec3f(0.f, 0.f, -1.f);              *forward = matMult4v(&rot, &dir); } I've already spent over 10 hours trying to get it right but couldn't manage to do it so far. My question is, is there a more clear and certain way of generating view matrix and camera directions?
  • Advertisement