Advertisement

Visual Studio DirectX issue

Started by April 19, 2020 09:47 PM
11 comments, last by yaboiryan 4 years, 7 months ago

I am trying to make a RTS game with DirectX.

I successfully got singleplayer working without any bugs that I would need to fix.

Now, I am trying to implement multiplayer.

While I successfully was able to make a client join a lobby, add a lobby chat, and add custom usernames/lobby names, I am getting a strange error when I start the game; more specifically when I am sending the terrain.

The error looks like this:

This seems to be an out of bounds error. You probably supplied an out of bounds index to a std::vector.

Advertisement

@Aerodactyl55 Thanks for your reply!

I just made another discovery. It is the client connecting to the server that is having all the issues. The server works on its own, but the client is the one that has a vector subscript error.

Running this in your debugger should help you find the cause.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

@21st Century Moose I am running the game from debug in Visual Studio. That is why I got the error. If I ran it in Release, the game would just crash.

When you get this error, click on “Retry”. At this point the application is stopped at the point of error in the Debugger. By going to the Callstack window, you can inspect to see where exactly in your code this invalid index is being specified.

Advertisement

@SBD It just points me to the vector header file. It says that it has triggered a breakpoint. Here is the surrounding code:

#if _ITERATOR_DEBUG_LEVEL == 2
 if (size() <= _Pos)
  { // report error
  _DEBUG_ERROR("vector subscript out of range");
  _SCL_SECURE_OUT_OF_RANGE;
  }

#elif _ITERATOR_DEBUG_LEVEL == 1
 _SCL_SECURE_VALIDATE_RANGE(_Pos < size());
#endif

When it breaks, look at the call stack. The first method in your own code should show the exact location where you accessed the std::vector out of bounds.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

@Endurion Ok so it sends me to the area where I am sending the terrain.

EDIT:

My computer is doing updates right now, so i will have the rest of the code to help you guys out in a few hours.

NET_OBJ object(terrain.objects[0]);

Can't really see much, but I assume terrain.objects is a std::vector? If it is, it is empty and you try to access the 0th element.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

This topic is closed to new replies.

Advertisement