Bugs and errata

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Source Code

      1. // TeapotWars.cpp
      2. void TeapotWarsLogic::VAddView(shared_ptr<IGameView> pView, ActorId actor)
      3. {
      4. BaseGameLogic::VAddView(pView, actor);
      5. if (dynamic_pointer_cast<TeapotWarsHumanView>(pView))
      6. {
      7. m_HumanPlayersAttached++;
      8. }
      9. else if (dynamic_pointer_cast<AITeapotView>(pView))
      10. {
      11. m_AIPlayersAttached++;
      12. }
      13. }
      Display All

      Not a bug or typo but dynamic casts here could probably be replaced by the call to virtual GameViewType VGetType()=0; of the IGameView.
      Looking for a job!
      My LinkedIn Profile
    • Good catch - I'm sure I meant to do that at some point but forgot.
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • Page 709 - concurrent_queue template example

      Source Code

      1. ...
      2. CriticalSection m_cs;
      3. HANDLE m_dataPushed;
      4. ...
      5. void push(Data const& data)
      6. {
      7. {
      8. ScopedCriticalSection locker(m_cs);
      9. the_queue.push(data);
      10. }
      11. PulseEvent(m_dataPushed);
      12. }
      13. ...
      14. void wait_and_pop(Data& popped_value)
      15. {
      16. ScopedCriticalSection locker(m_cs);
      17. while(the_queue.empty())
      18. {
      19. WaitForSingleObject(m_dataPushed);
      20. }
      21. popped_value=the_queue.front();
      22. the_queue.pop();
      23. }
      Display All


      I'm not sure about this but I'll give it a try with my broken english. :)

      Wouldn't wait_and_pop(...) for an empty queue block the entire queue?

      assume that:

      Thread A calls wait_and_pop(), locks the critical section and hangs in the loop waiting for the event 'm_dataPushed' to be signaled.

      Thread B tries to push a value but cannot enter the critical section because Thread A already locked the section.
    • Spelling hiccups

      Two small spelling ones I've noticed (I emailed about the first; as you can see my account here is now working--thanks!):
      • On page 364, the Lua example at the top has "Sqaure(5)" instead of
        "Square(5)"
      • On page 604, the example uses "pRidigBody" instead of "pRigidBody"

    • Just found out that in C++ deleting null pointer with standard operator delete has no effect (delete (C++)). Do we need if check then in SAFE_DELETE and SAFE_DELETE_ARRAY macro defined in GameCodeStd.h?


      As you said, trying to delete a nullptr has no effect, so that check is not really necessary. I don't know though whether or not that check would bring any performance benefits.
    • Typos in Chapter 8

      Found a bunch of typos today and was asked to put them in the forum instead of using emails.

      Page 198, last paragraph: "These data structures are called triangle lists or triangle fans."
      Should actually say: "These data structures are called triangle strips or triangle fans."

      The triangle list is the structure above with 3 vertices per triangle.

      Page 206, third paragraph: "3.4MHz" should be changed to "3.4KHz" since the Signal is sampled at 8KHz.

      Page 209, table 8.4: 16x DVD should be "22.1 Mbps" rather than "2.21 Mbps"
    • Error in ProcessManager with REMOVED Processes?

      Hi,

      Just a minor inconsistence / bug in the code. Its stated that REMOVED flag is for processes that were running but must be swaped out (ie reparented or whatever). In this use case (reparenting) I guess the Process::AttachChild method should test the state of the attached Process, and if it was RUNNING / PAUSED change it to REMOVED.

      Other issue is that REMOVED processes are not processed in any way at ProcessManager::UpdateProcesses method. I guess the REMOVED is intended for delaying the removal to the next time the ProcessManager updates the process.

      When the method checks for IsDead() it should also check for IsRemoved() and erase it.