Compare commits

...

56 Commits

Author SHA1 Message Date
William Moberg bc3c8299e8 Moved minidump code to MiniDump.cpp from main. 2016-03-04 03:05:09 +01:00
verysecrethero dc88074f7f Merge remote-tracking branch 'origin/master' into MiniDump 2016-03-03 17:03:06 +01:00
verysecrethero db09d93111 Minidump stage 2 fix 2016-03-03 16:41:47 +01:00
verysecrethero cc34f53b16 Memorydump stage 1 fix 2016-03-03 16:07:35 +01:00
Tobias Dahl fe36e8b423 Merge pull request #164 from teamfisk/FixNetworkBugs
Fixed invisible players and connect crash.
2016-03-03 15:57:02 +01:00
stiffly a7bff92899 The readBuffer now checks if the whole packet has arrived before attempting to parse it. 2016-03-03 15:16:42 +01:00
Tobias Dahl bfcf7b240e Merge pull request #163 from teamfisk/revert-145-Shadows
Revert "Shadows"
2016-03-03 14:25:10 +01:00
Tobias Dahl 73b8bff1f3 Revert "Shadows" 2016-03-03 14:24:43 +01:00
Tobias Dahl 1deb506fb2 Merge pull request #145 from teamfisk/Shadows
Shadows
2016-03-03 14:06:48 +01:00
Jocke ae3cab6cd1 Merge remote-tracking branch 'origin/master' into FixNetworkBugs 2016-03-03 13:31:43 +01:00
Jocke a9b19d9af1 Packet write now only warns when a a packet is huge 2016-03-03 13:29:45 +01:00
Jocke cb7beae28c Only do physics and collision calculations on the clients side, and only for their own entity. 2016-03-03 11:39:00 +01:00
FakeShemp 7ea26d10ee Rewritten. Works as a charm now. 2016-03-03 03:28:21 +01:00
FakeShemp 28e9ba1208 Merge branch 'master' into Shadows
# Conflicts:
#	include/Engine/Rendering/DrawFinalPass.h
#	src/Engine/Rendering/DrawFinalPass.cpp
#	src/Engine/Rendering/FrameBuffer.cpp
#	src/Engine/Rendering/Renderer.cpp
2016-03-03 03:00:05 +01:00
Tobias Dahl f0c2fdead1 Merge pull request #156 from teamfisk/HUD-Timers
Hud timers for dash ability
2016-03-02 22:53:25 +01:00
Jocke 85ba5552e9 Merge remote-tracking branch 'origin/master' into FixNetworkBugs 2016-03-02 17:59:20 +01:00
Jocke 0a6653d079 Merge remote-tracking branch 'origin/master' into FixNetworkBugs 2016-03-02 17:06:24 +01:00
Jocke cfba8efd24 WritePrimitive would spam a warning when snapshots got bigger than 512 and it got resized. 2016-03-02 10:59:03 +01:00
FakeShemp 5a6374f013 Fix the remainder of errors. Might have borked splatmap in the process. 2016-03-02 10:57:22 +01:00
FakeShemp 1ae2f3f5f3 Begin clean-up 2016-03-01 19:10:13 +01:00
FakeShemp 1961c16fe2 add weight slider 2016-03-01 13:27:52 +01:00
FakeShemp d32a483bb4 remove farclip override 2016-03-01 13:17:17 +01:00
FakeShemp e23ea78aeb Merge remote-tracking branch 'origin/master' into Shadows
# Conflicts:
#	resources/Shaders/ForwardPlus.frag.glsl
2016-03-01 13:04:11 +01:00
FakeShemp 4153a31e3a Fix goof. 2016-02-29 19:47:24 +01:00
FakeShemp 0908be1e02 Shadows are pretty much done. 2016-02-29 19:45:56 +01:00
FakeShemp 2ed5fad699 The shadows are working 2016-02-29 19:17:16 +01:00
FakeShemp 70374fa10e It compiles, but no shadows 2016-02-29 18:20:32 +01:00
FakeShemp 20468cba1b Merge branch 'master' into Shadows
# Conflicts:
#	assets
#	include/Engine/Rendering/DrawFinalPass.h
#	include/Engine/Rendering/Renderer.h
#	resources/Shaders/ForwardPlus.frag.glsl
#	resources/Shaders/ForwardPlus.vert.glsl
#	src/Engine/Rendering/DrawFinalPass.cpp
#	src/Engine/Rendering/FrameBuffer.cpp
#	src/Engine/Rendering/Renderer.cpp
2016-02-29 18:03:00 +01:00
FakeShemp 7749fc5474 Small fixing up 2016-02-28 19:46:50 +01:00
FakeShemp 6dd7f1a657 Buggy transparent shadows.
Transparent textures might glow.
2016-02-28 18:00:23 +01:00
FakeShemp 14b0a64720 begin fixing transparent object's shadows 2016-02-27 18:42:51 +01:00
FakeShemp 8647267cad Make code less dumb, save 7 fps 2016-02-27 18:04:33 +01:00
FakeShemp ecab5de056 Various shadow calculation methods implemented and ready for use. 2016-02-27 16:35:15 +01:00
FakeShemp 38d8cdded2 Texture Array is now working. Enjoy your single Bind(). 2016-02-27 15:53:28 +01:00
FakeShemp 22c391df54 Initial work on texture arrays 2016-02-26 17:40:35 +01:00
FakeShemp f220d8088c Begin clean-up 2016-02-26 10:53:16 +01:00
FakeShemp df2e4abb52 WE HAVE WORKING CASCADE SHADOWS 2016-02-25 21:21:38 +01:00
FakeShemp 8867e7ac3c Working shadows, no cascade blend yet 2016-02-25 20:29:41 +01:00
William Moberg 05bbecc452 WIP, minidump is done in another program, started from our app.
The other program is not in git yet.
2016-02-24 17:23:47 +01:00
William Moberg a36deb2cf9 WIP, trying to figure out why minidumps doesn't work. 2016-02-23 18:19:48 +01:00
FakeShemp 73a4336206 Try some stuff 2016-02-18 23:33:10 +01:00
FakeShemp f2ab02d860 More WIP
Switching between levels seem to work, but I borked all matrices
2016-02-18 22:38:50 +01:00
FakeShemp bf376f54b6 WIP
I think this is now finding the different segments of the cascade
2016-02-18 20:48:39 +01:00
FakeShemp 178402e964 cascade shadow wip 2016-02-18 10:08:29 +01:00
FakeShemp 36043010af wip for shadows
they work, but will be shit until we get cascaded.
2016-02-10 20:51:33 +01:00
FakeShemp cb77c1ff97 Working pcf, not optimized 2016-02-10 16:16:41 +01:00
FakeShemp 69db32337d Shado wip 2016-02-10 15:16:58 +01:00
Ayumiwii 6af167675d Shadow WIP stage 2
- fix cel-shading
2016-02-10 11:48:44 +01:00
Ayumiwii ecd823cb9f Shadow WIP stage 2
-  Soft shadow
2016-02-09 16:15:11 +01:00
FakeShemp 847c539373 Fix viewport 2016-02-09 14:44:12 +01:00
Ayumiwii cb7f06573f Shadows stage 2 WIP 2016-02-09 14:08:57 +01:00
Ayumiwii 6542d1b444 Shadow WIP
- DepthTexture working
2016-02-05 17:29:53 +01:00
Ayumiwii bbf6058c17 Shadow WIP
- fixed file placing of ShadowPass.cpp
2016-02-05 16:13:46 +01:00
Ayumiwii 0e51ae7dc9 shadow wip 2016-02-05 15:31:20 +01:00
Ayumiwii c912cd7a42 Shadows wip 2016-02-05 15:12:17 +01:00
Ayumiwii 7f1016476b Shadows WIP
- create 2D texture (depthmap)
2016-02-05 15:08:56 +01:00
11 changed files with 194 additions and 194 deletions
+3 -1
View File
@@ -24,7 +24,9 @@ public:
{ {
// Check if we are trying to add more than the package can fit. // Check if we are trying to add more than the package can fit.
if (m_MaxPacketSize < m_Offset + sizeof(T)) { if (m_MaxPacketSize < m_Offset + sizeof(T)) {
LOG_WARNING("Packet AddPrimitive(): You are trying to add more than we have allocated for! New size is %i bytes\n", m_MaxPacketSize*2); if (m_MaxPacketSize >= 32000) {
LOG_WARNING("Package::WritePrimitive(): New size is huge %i bytes\n", m_MaxPacketSize*2);
}
resizeData(); resizeData();
} }
memcpy(m_Data + m_Offset, &val, sizeof(T)); memcpy(m_Data + m_Offset, &val, sizeof(T));
+2 -1
View File
@@ -2,7 +2,8 @@
#define MiniDump_h__ #define MiniDump_h__
#include <Windows.h> #include <Windows.h>
#include <DbgHelp.h>
void WINAPI Create_Dump(PEXCEPTION_POINTERS pException, BOOL File_Flag, BOOL Show_Flag); long WINAPI Create_Dump_Immediate(LPEXCEPTION_POINTERS pException);
#endif #endif
+84 -82
View File
@@ -17,105 +17,107 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
EntityAABB& boxA = *boundingBox; EntityAABB& boxA = *boundingBox;
bool everHitTheGround = false; bool everHitTheGround = false;
auto prevPosIt = m_PrevPositions.find(entity); if (entity == LocalPlayer) {
if (prevPosIt != m_PrevPositions.end()) { auto prevPosIt = m_PrevPositions.find(entity);
glm::vec3 size = boxA.Size(); if (prevPosIt != m_PrevPositions.end()) {
float diameter = std::min(size.x, size.z); glm::vec3 size = boxA.Size();
glm::vec3 prevOrigin = prevPosIt->second; float diameter = std::min(size.x, size.z);
glm::vec3 toCurrentPos = boxA.Origin() - prevOrigin; glm::vec3 prevOrigin = prevPosIt->second;
float rayLength = glm::length(toCurrentPos) + 0.5f*diameter; glm::vec3 toCurrentPos = boxA.Origin() - prevOrigin;
//If the entity has moved farther than the size of its box, we need to handle it specially. float rayLength = glm::length(toCurrentPos) + 0.5f*diameter;
if (rayLength > diameter) { //If the entity has moved farther than the size of its box, we need to handle it specially.
Ray ray(prevOrigin, toCurrentPos); if (rayLength > diameter) {
m_OctreeResult.clear(); Ray ray(prevOrigin, toCurrentPos);
m_Octree->ObjectsPossiblyHitByRay(ray, m_OctreeResult); m_OctreeResult.clear();
for (auto& boxB : m_OctreeResult) { m_Octree->ObjectsPossiblyHitByRay(ray, m_OctreeResult);
if (boxA.Entity == boxB.Entity) { for (auto& boxB : m_OctreeResult) {
continue; if (boxA.Entity == boxB.Entity) {
}
bool hit;
float dist;
if (boxB.Entity.HasComponent("Model")) {
RawModel* model;
std::string res = (std::string)boxB.Entity["Model"]["Resource"];
try {
model = ResourceManager::Load<RawModel, true>(res);
} catch (const std::exception&) {
continue; continue;
} }
float u, v; bool hit;
hit = Collision::RayVsModel(ray, model->Vertices(), model->m_Indices, Transform::ModelMatrix(boxB.Entity), dist, u, v); float dist;
} else { if (boxB.Entity.HasComponent("Model")) {
hit = Collision::RayVsAABB(ray, boxB, dist); RawModel* model;
} std::string res = (std::string)boxB.Entity["Model"]["Resource"];
if (hit && dist < rayLength) { try {
//Set the entity to where it was colliding, minus the maximum box size. model = ResourceManager::Load<RawModel, true>(res);
//TODO: Perhaps this should be done slightly more properly. } catch (const std::exception&) {
glm::vec3 newOriginPos = ray.Origin() + (dist - 0.707107f*diameter) * ray.Direction(); continue;
glm::vec3 resolve = newOriginPos - boxA.Origin(); }
(glm::vec3&)cTransform["Position"] += resolve; float u, v;
boxA = *Collision::EntityAbsoluteAABB(entity); hit = Collision::RayVsModel(ray, model->Vertices(), model->m_Indices, Transform::ModelMatrix(boxB.Entity), dist, u, v);
if (resolve.y > 0) { } else {
everHitTheGround = true; hit = Collision::RayVsAABB(ray, boxB, dist);
(bool)cPhysics["IsOnGround"] = true; }
((glm::vec3&)cPhysics["Velocity"]).y = 0.f; if (hit && dist < rayLength) {
//Set the entity to where it was colliding, minus the maximum box size.
//TODO: Perhaps this should be done slightly more properly.
glm::vec3 newOriginPos = ray.Origin() + (dist - 0.707107f*diameter) * ray.Direction();
glm::vec3 resolve = newOriginPos - boxA.Origin();
(glm::vec3&)cTransform["Position"] += resolve;
boxA = *Collision::EntityAbsoluteAABB(entity);
if (resolve.y > 0) {
everHitTheGround = true;
(bool)cPhysics["IsOnGround"] = true;
((glm::vec3&)cPhysics["Velocity"]).y = 0.f;
}
break;
} }
break;
} }
} }
} }
}
// Collide against octree items // Collide against octree items
m_OctreeResult.clear(); m_OctreeResult.clear();
m_Octree->ObjectsInSameRegion(*boundingBox, m_OctreeResult); m_Octree->ObjectsInSameRegion(*boundingBox, m_OctreeResult);
for (auto& boxB : m_OctreeResult) { for (auto& boxB : m_OctreeResult) {
glm::vec3 resolutionVector; glm::vec3 resolutionVector;
if (boxA.Entity == boxB.Entity) { if (boxA.Entity == boxB.Entity) {
continue;
}
if (boxB.Entity.HasComponent("Model") && Collision::AABBVsAABB(boxA, boxB)) {
//Here we know boxB is a entity with Collideable, AABB, and Model.
RawModel* model;
try {
model = ResourceManager::Load<RawModel, true>(boxB.Entity["Model"]["Resource"]);
} catch (const std::exception&) {
continue; continue;
} }
glm::mat4 modelMatrix = Transform::ModelMatrix(boxB.Entity); if (boxB.Entity.HasComponent("Model") && Collision::AABBVsAABB(boxA, boxB)) {
//Here we know boxB is a entity with Collideable, AABB, and Model.
RawModel* model;
try {
model = ResourceManager::Load<RawModel, true>(boxB.Entity["Model"]["Resource"]);
} catch (const std::exception&) {
continue;
}
glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"]; glm::mat4 modelMatrix = Transform::ModelMatrix(boxB.Entity);
bool notMovingxz = glm::all(glm::lessThan(glm::abs(glm::vec2(inOutVelocity.x, inOutVelocity.z)), glm::vec2(0.01f))) && prevPosIt != m_PrevPositions.end();
bool isOnGround = (bool)cPhysics["IsOnGround"]; glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"];
float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"]; bool notMovingxz = glm::all(glm::lessThan(glm::abs(glm::vec2(inOutVelocity.x, inOutVelocity.z)), glm::vec2(0.01f))) && prevPosIt != m_PrevPositions.end();
if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) { bool isOnGround = (bool)cPhysics["IsOnGround"];
//Move the position to previous position if it is not moving in the xz-plane, else resolve with the resolution vector. float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"];
(glm::vec3&)cTransform["Position"] += notMovingxz ? prevPosIt->second - boxA.Origin() : resolutionVector; if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) {
//Move the position to previous position if it is not moving in the xz-plane, else resolve with the resolution vector.
(glm::vec3&)cTransform["Position"] += notMovingxz ? prevPosIt->second - boxA.Origin() : resolutionVector;
boxA = *Collision::EntityAbsoluteAABB(entity);
cPhysics["Velocity"] = inOutVelocity;
if (isOnGround) {
everHitTheGround = true;
(bool)cPhysics["IsOnGround"] = true;
}
}
} else if (Collision::AABBVsAABB(boxA, boxB, resolutionVector)) {
//Enter here if boxB has no Model.
(glm::vec3&)cTransform["Position"] += resolutionVector;
boxA = *Collision::EntityAbsoluteAABB(entity); boxA = *Collision::EntityAbsoluteAABB(entity);
cPhysics["Velocity"] = inOutVelocity; if (resolutionVector.y > 0) {
if (isOnGround) {
everHitTheGround = true; everHitTheGround = true;
(bool)cPhysics["IsOnGround"] = true; (bool)cPhysics["IsOnGround"] = true;
((glm::vec3&)cPhysics["Velocity"]).y = 0.f;
} }
} }
} else if (Collision::AABBVsAABB(boxA, boxB, resolutionVector)) {
//Enter here if boxB has no Model.
(glm::vec3&)cTransform["Position"] += resolutionVector;
boxA = *Collision::EntityAbsoluteAABB(entity);
if (resolutionVector.y > 0) {
everHitTheGround = true;
(bool)cPhysics["IsOnGround"] = true;
((glm::vec3&)cPhysics["Velocity"]).y = 0.f;
}
} }
}
//This should apply air friction and such, iff zero models were hit. //This should apply air friction and such, iff zero models were hit.
if (!everHitTheGround) { if (!everHitTheGround) {
(bool)cPhysics["IsOnGround"] = false; (bool)cPhysics["IsOnGround"] = false;
} }
m_PrevPositions[entity] = boxA.Origin(); m_PrevPositions[entity] = boxA.Origin();
}
} }
+10 -4
View File
@@ -49,18 +49,24 @@ void Packet::WriteString(const std::string& str)
// Message, add one extra byte for null terminator // Message, add one extra byte for null terminator
size_t sizeOfString = str.size() + 1; size_t sizeOfString = str.size() + 1;
if (m_Offset + sizeOfString > m_MaxPacketSize) { if (m_Offset + sizeOfString > m_MaxPacketSize) {
//LOG_WARNING("Package::WriteString(): Data size in packet exceeded maximum package size. New size is %i bytes\n", m_MaxPacketSize*2); if (m_MaxPacketSize >= 32000) {
LOG_WARNING("Package::WriteString(): New size is huge %i bytes\n", m_MaxPacketSize*2);
}
resizeData(); resizeData();
} }
memcpy(m_Data + m_Offset, str.data(), sizeOfString * sizeof(char)); memcpy(m_Data + m_Offset, str.data(), str.size() * sizeof(char));
m_Offset += sizeOfString * sizeof(char); m_Offset += str.size() * sizeof(char);
m_Data[m_Offset] = '\0';
m_Offset += 1;
} }
void Packet::WriteData(char * data, int sizeOfData) void Packet::WriteData(char * data, int sizeOfData)
{ {
if (m_Offset + sizeOfData > m_MaxPacketSize) { if (m_Offset + sizeOfData > m_MaxPacketSize) {
//LOG_WARNING("Packet::WriteData(): Data size in packet exceeded maximum packet size. New size is %i bytes\n", m_MaxPacketSize*2); if (m_MaxPacketSize >= 32000) {
LOG_WARNING("Package::WriteData(): New size is huge %i bytes\n", m_MaxPacketSize*2);
}
while (m_Offset + sizeOfData > m_MaxPacketSize) { while (m_Offset + sizeOfData > m_MaxPacketSize) {
resizeData(); resizeData();
} }
+4 -1
View File
@@ -74,7 +74,10 @@ size_t TCPClient::readBuffer()
boost::asio::ip::tcp::socket::message_peek, error); boost::asio::ip::tcp::socket::message_peek, error);
unsigned int sizeOfPacket = 0; unsigned int sizeOfPacket = 0;
memcpy(&sizeOfPacket, m_ReadBuffer, sizeof(int)); memcpy(&sizeOfPacket, m_ReadBuffer, sizeof(int));
if (sizeOfPacket > m_Socket->available()) {
LOG_WARNING("TCPClient::readBuffer(): We haven't got the whole packet yet.");
return 0;
}
// if the buffer is to small increase the size of it // if the buffer is to small increase the size of it
// TODO if message is huge 1 time the buffer will not decrease. // TODO if message is huge 1 time the buffer will not decrease.
if (sizeOfPacket > m_BufferSize) { if (sizeOfPacket > m_BufferSize) {
+4 -1
View File
@@ -106,7 +106,10 @@ int TCPServer::readBuffer(PlayerDefinition & playerDefinition)
boost::asio::ip::tcp::socket::message_peek, error); boost::asio::ip::tcp::socket::message_peek, error);
unsigned int sizeOfPacket = 0; unsigned int sizeOfPacket = 0;
memcpy(&sizeOfPacket, m_ReadBuffer, sizeof(int)); memcpy(&sizeOfPacket, m_ReadBuffer, sizeof(int));
if (sizeOfPacket > playerDefinition.TCPSocket->available()) {
LOG_WARNING("TCPServer::readBuffer(): We haven't got the whole packet yet.");
return 0;
}
// if the buffer is to small increase the size of it // if the buffer is to small increase the size of it
if (sizeOfPacket > m_BufferSize) { if (sizeOfPacket > m_BufferSize) {
delete[] m_ReadBuffer; delete[] m_ReadBuffer;
+4 -1
View File
@@ -45,7 +45,10 @@ int UDPClient::readBuffer()
boost::asio::ip::udp::socket::message_peek, error); boost::asio::ip::udp::socket::message_peek, error);
int sizeOfPacket = 0; int sizeOfPacket = 0;
memcpy(&sizeOfPacket, m_ReadBuffer, sizeof(int)); memcpy(&sizeOfPacket, m_ReadBuffer, sizeof(int));
if (sizeOfPacket > m_Socket->available()) {
LOG_WARNING("UDPClient::readBuffer(): We haven't got the whole packet yet.");
return 0;
}
// if the buffer is to small increase the size of it // if the buffer is to small increase the size of it
if (sizeOfPacket > m_BufferSize) { if (sizeOfPacket > m_BufferSize) {
delete[] m_ReadBuffer; delete[] m_ReadBuffer;
+5
View File
@@ -92,6 +92,11 @@ int UDPServer::readBuffer()
unsigned int sizeOfPacket = 0; unsigned int sizeOfPacket = 0;
memcpy(&sizeOfPacket, m_ReadBuffer, sizeof(int)); memcpy(&sizeOfPacket, m_ReadBuffer, sizeof(int));
if (sizeOfPacket > m_Socket->available()) {
LOG_WARNING("UDPServer::readBuffer(): We haven't got the whole packet yet.");
return 0;
}
// if the buffer is to small increase the size of it // if the buffer is to small increase the size of it
if (sizeOfPacket > m_BufferSize) { if (sizeOfPacket > m_BufferSize) {
delete[] m_ReadBuffer; delete[] m_ReadBuffer;
+71 -80
View File
@@ -1,110 +1,101 @@
/* /*
Author: Vladimir Sedach. Inspired by Original Author: Vladimir Sedach.
Purpose: demo of Call Stack creation by our own means, Purpose: demo of Call Stack creation by our own means,
and with MiniDumpWriteDump() function of DbgHelp.dll. and with MiniDumpWriteDump() function of DbgHelp.dll.
*/ */
#include "MiniDump.h"
#include <string>
#include <iostream> #include <iostream>
#include <ctime> #include <ctime>
#include <comdef.h>
#include <windows.h> #pragma optimize("y", off) //generate stack frame pointers for all functions - same as /Oy- in the project
#include <tlhelp32.h> #pragma warning(disable: 4200) //nonstandard extension used : zero-sized array in struct/union
//#include "dbghelp.h" #pragma warning(disable: 4100) //unreferenced formal parameter
//#define DEBUG_DPRINTF 1 //allow d() typedef BOOL(WINAPI * MINIDUMP_WRITE_DUMP)(
//#include "wfun.h" IN HANDLE hProcess,
IN DWORD ProcessId,
#pragma optimize("y", off) //generate stack frame pointers for all functions - same as /Oy- in the project IN HANDLE hFile,
#pragma warning(disable: 4200) //nonstandard extension used : zero-sized array in struct/union IN MINIDUMP_TYPE DumpType,
#pragma warning(disable: 4100) //unreferenced formal parameter IN CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, OPTIONAL
IN PVOID UserStreamParam, OPTIONAL
// In case you don't have dbghelp.h. IN PVOID CallbackParam OPTIONAL
#ifndef _DBGHELP_ );
typedef struct _MINIDUMP_EXCEPTION_INFORMATION {
DWORD ThreadId;
PEXCEPTION_POINTERS ExceptionPointers;
BOOL ClientPointers;
} MINIDUMP_EXCEPTION_INFORMATION, *PMINIDUMP_EXCEPTION_INFORMATION;
typedef enum _MINIDUMP_TYPE {
MiniDumpNormal = 0x00000000,
MiniDumpWithDataSegs = 0x00000001,
} MINIDUMP_TYPE;
typedef BOOL (WINAPI * MINIDUMP_WRITE_DUMP)(
IN HANDLE hProcess,
IN DWORD ProcessId,
IN HANDLE hFile,
IN MINIDUMP_TYPE DumpType,
IN CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, OPTIONAL
IN PVOID UserStreamParam, OPTIONAL
IN PVOID CallbackParam OPTIONAL
);
#else
typedef BOOL (WINAPI * MINIDUMP_WRITE_DUMP)(
IN HANDLE hProcess,
IN DWORD ProcessId,
IN HANDLE hFile,
IN MINIDUMP_TYPE DumpType,
IN CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, OPTIONAL
IN PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, OPTIONAL
IN PMINIDUMP_CALLBACK_INFORMATION CallbackParam OPTIONAL
);
#endif //#ifndef _DBGHELP_
HMODULE hDbgHelp;
MINIDUMP_WRITE_DUMP MiniDumpWriteDump_;
// Tool Help functions.
typedef HANDLE (WINAPI * CREATE_TOOL_HELP32_SNAPSHOT)(DWORD dwFlags, DWORD th32ProcessID);
//************************************************************************************* //*************************************************************************************
void WINAPI Create_Dump(PEXCEPTION_POINTERS pException, BOOL File_Flag, BOOL Show_Flag) long WINAPI Create_Dump_Immediate(LPEXCEPTION_POINTERS pException)
//************************************************************************************* //*************************************************************************************
// Create dump. // Create dump.
// pException can be either GetExceptionInformation() or NULL. // pException can be either GetExceptionInformation() or NULL.
// If File_Flag = TRUE - write dump files (.dmz and .dmp) with the name of the current process.
// If Show_Flag = TRUE - show message with Get_Exception_Info() dump.
{ {
// Try to get MiniDumpWriteDump() address. // Try to get MiniDumpWriteDump() address.
hDbgHelp = LoadLibrary("DBGHELP.DLL"); HMODULE hDbgHelp = LoadLibrary("DBGHELP.DLL");
MiniDumpWriteDump_ = (MINIDUMP_WRITE_DUMP)GetProcAddress(hDbgHelp, "MiniDumpWriteDump"); MINIDUMP_WRITE_DUMP MiniDumpWriteDump_ = (MINIDUMP_WRITE_DUMP)GetProcAddress(hDbgHelp, "MiniDumpWriteDump");
// If MiniDumpWriteDump() of DbgHelp.dll available. // If MiniDumpWriteDump() of DbgHelp.dll available.
if (MiniDumpWriteDump_) if (MiniDumpWriteDump_) {
{ // Get absolute path of current process: C:/ ... /name.exe
HANDLE hDump_File; CHAR Dump_Path[MAX_PATH];
CHAR Dump_Path[MAX_PATH]; GetModuleFileName(NULL, Dump_Path, sizeof(Dump_Path));
std::string path(Dump_Path);
GetModuleFileName(NULL, Dump_Path, sizeof(Dump_Path)); //path of current process // Get current time in a string.
std::time_t t = std::time(NULL); std::time_t t = std::time(NULL);
char tStr[16]; char tStr[16];
std::strftime(tStr, 32, " %a %H-%M-%S", std::localtime(&t)); std::strftime(tStr, ARRAYSIZE(tStr), " %a %H-%M-%S", std::localtime(&t));
std::string time(tStr); std::string time(tStr);
std::string path(Dump_Path); // Remove the .exe from path
path = path.substr(0, path.length() - 4); path = path.substr(0, path.length() - 4);
path += time + ".dmp"; // Add the current time and .dmp
path += "dump" + time + ".dmp";
MINIDUMP_EXCEPTION_INFORMATION M; DWORD procId = GetCurrentProcessId();
M.ThreadId = GetCurrentThreadId(); DWORD threadId = GetCurrentThreadId();
M.ExceptionPointers = pException;
M.ClientPointers = 0;
hDump_File = CreateFile(path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); MINIDUMP_EXCEPTION_INFORMATION M;
M.ThreadId = threadId;
M.ExceptionPointers = pException;
M.ClientPointers = TRUE;
MiniDumpWriteDump_(GetCurrentProcess(), GetCurrentProcessId(), hDump_File, HANDLE hDump_File = CreateFile(path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
MiniDumpNormal, (pException) ? &M : NULL, NULL, NULL); HANDLE process = GetCurrentProcess();
CloseHandle(hDump_File); BOOL result = MiniDumpWriteDump_(process, procId, hDump_File
, (MINIDUMP_TYPE)(MiniDumpWithDataSegs |
MiniDumpWithHandleData |
MiniDumpScanMemory |
MiniDumpWithUnloadedModules |
MiniDumpWithIndirectlyReferencedMemory |
MiniDumpWithPrivateReadWriteMemory |
MiniDumpWithFullMemoryInfo |
MiniDumpWithThreadInfo |
MiniDumpIgnoreInaccessibleMemory)
, &M, NULL, NULL);
HRESULT error = (HRESULT)GetLastError();
std::cout << "Memory dumped to: \"" << path.c_str() << "\""; CloseHandle(hDump_File);
MessageBox(NULL, ("Application crashed, memory dumped to: " + path).c_str(), "MiniDump", MB_ICONHAND | MB_OK); if (!result) {
_com_error cErr(error);
HRESULT actualErrorCode = error & 0xFFFF;
char hexErrBuf[16];
std::sprintf(hexErrBuf, "0x%x", actualErrorCode);
std::cout << "Bad memory dump at: \"" << path.c_str() << "\"" << std::endl
<< "because MiniDumpWriteDump failed with error #" << actualErrorCode << " (" << hexErrBuf << "): \"" << cErr.ErrorMessage() << "\"" << std::endl;
MessageBox(NULL, "Application crashed, memory dump failed, but file was created.", "MiniDump", MB_ICONHAND | MB_OK);
} else {
std::cout << "Memory dumped to: \"" << path.c_str() << "\"" << std::endl;
MessageBox(NULL, ("Application crashed, memory dumped to: " + path).c_str(), "MiniDump", MB_ICONHAND | MB_OK);
}
} else { } else {
MessageBox(NULL, "Application crashed, memory dump failed.", "MiniDump", MB_ICONHAND | MB_OK); std::cout << "Memory dump failed because MiniDumpWriteDump is not available." << std::endl;
MessageBox(NULL, "Application crashed, could not create a memory dump.", "MiniDump", MB_ICONHAND | MB_OK);
} }
// Basically, terminate the application.
return EXCEPTION_EXECUTE_HANDLER;
} }
+3 -8
View File
@@ -18,14 +18,9 @@ PlayerMovementSystem::~PlayerMovementSystem()
void PlayerMovementSystem::Update(double dt) void PlayerMovementSystem::Update(double dt)
{ {
updateMovementControllers(dt); updateMovementControllers(dt);
if (IsServer) { // Only do physics calculations on client and only for themselves.
for (auto& kv : m_PlayerInputControllers) { if (IsClient && LocalPlayer.Valid()) {
updateVelocity(kv.first, dt); updateVelocity(LocalPlayer, dt);
}
} else {
if (LocalPlayer.Valid()) {
updateVelocity(LocalPlayer, dt);
}
} }
} }
+4 -15
View File
@@ -1,27 +1,16 @@
#include "Game.h" #include "Game.h"
#include "MiniDump.h" #include "MiniDump.h"
LONG WINAPI CrashHandler(EXCEPTION_POINTERS* pException);
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
::SetUnhandledExceptionFilter(CrashHandler); SetUnhandledExceptionFilter(Create_Dump_Immediate);
Game game(argc, argv); Game game(argc, argv);
while (game.Running()) { while (game.Running()) {
PerformanceTimer::StartTimer("Game-Tick"); PerformanceTimer::StartTimer("Game-Tick");
game.Tick(); game.Tick();
PerformanceTimer::StopTimer("Game-Tick"); PerformanceTimer::StopTimer("Game-Tick");
} }
return 0; return 0;
} }
LONG WINAPI CrashHandler(EXCEPTION_POINTERS* pException)
{
//Take minidump. path should be bin/TacticalZ.dmp
//Then show MessageBox, and exit application.
Create_Dump(pException, 1, 1);
return EXCEPTION_EXECUTE_HANDLER;// EXCEPTION_CONTINUE_SEARCH
}