Renamed WriteAngles to WriteAngle. Made use of WriteAngle and WriteVector

This commit is contained in:
Jordan Cristiano 2015-07-13 23:19:55 -04:00
parent fed62e14a4
commit d3b8873481
7 changed files with 35 additions and 46 deletions

View File

@ -33,11 +33,11 @@ void DemoJsonWriter::WriteCmdInfo(base::JsonWriterFile& writer,
writer.StartObject("democmdinfo");
writer.WriteInt32("flags", split.flags);
WriteVector(writer, "viewOrigin", split.viewOrigin);
WriteAngles(writer, "viewAngles", split.viewAngles);
WriteAngles(writer, "localViewAngles", split.localViewAngles);
WriteAngle(writer, "viewAngles", split.viewAngles);
WriteAngle(writer, "localViewAngles", split.localViewAngles);
WriteVector(writer, "viewOrigin2", split.viewOrigin2);
WriteAngles(writer, "viewAngles2", split.viewAngles2);
WriteAngles(writer, "localViewAngles2", split.localViewAngles2);
WriteAngle(writer, "viewAngles2", split.viewAngles2);
WriteAngle(writer, "localViewAngles2", split.localViewAngles2);
writer.EndObject();
}
@ -59,7 +59,7 @@ void DemoJsonWriter::WriteVector(base::JsonWriterFile& writer, const char* name,
writer.EndObject();
}
void DemoJsonWriter::WriteAngles(base::JsonWriterFile& writer, const char* name, const QAngle& angles)
void DemoJsonWriter::WriteAngle(base::JsonWriterFile& writer, const char* name, const QAngle& angles)
{
writer.StartObject(name);
writer.WriteFloat("pitch", angles.x);

View File

@ -17,5 +17,5 @@ namespace DemoJsonWriter
void WriteCmdInfo(base::JsonWriterFile& writer, const democmdinfo_t& info);
void WriteUserCmd(base::JsonWriterFile& writer, int32_t cmdNum, const uint8_t* buffer, int32_t length);
void WriteVector(base::JsonWriterFile& writer, const char* name, const Vector& vec);
void WriteAngles(base::JsonWriterFile& writer, const char* name, const QAngle& angles);
};
void WriteAngle(base::JsonWriterFile& writer, const char* name, const QAngle& angle);
}

View File

@ -2,6 +2,7 @@
#include "svc_bspdecal.h"
#include "base/bitfile.h"
#include "base/jsonfile.h"
#include "demofile/demojson.h"
#include "netcontants.h"
namespace NetHandlers
@ -50,11 +51,7 @@ namespace NetHandlers
bool SVC_BSPDecal_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_BSPDecal* data)
{
jsonbuf.StartObject("svc_bspdecal");
jsonbuf.StartObject("position");
jsonbuf.WriteFloat("x", data->position.x);
jsonbuf.WriteFloat("y", data->position.y);
jsonbuf.WriteFloat("z", data->position.z);
jsonbuf.EndObject();
DemoJsonWriter::WriteVector(jsonbuf, "position", data->position);
jsonbuf.WriteUInt32("decalTextureIndex", data->decalTextureIndex);
jsonbuf.WriteUInt32("entIndex", data->entIndex);
jsonbuf.WriteUInt32("modelIndex", data->modelIndex);

View File

@ -2,23 +2,24 @@
#include "svc_crosshairangle.h"
#include "base/bitfile.h"
#include "base/jsonfile.h"
#include "demofile/demojson.h"
#include <iomanip>
namespace NetHandlers
{
bool SVC_CrosshairAngle_BitRead_Internal(BitRead& bitbuf, SourceGameContext& context, NetMsg::SVC_CrosshairAngle* data)
{
data->x = bitbuf.ReadBitAngle(16);
data->y = bitbuf.ReadBitAngle(16);
data->z = bitbuf.ReadBitAngle(16);
data->angle.x = bitbuf.ReadBitAngle(16);
data->angle.y = bitbuf.ReadBitAngle(16);
data->angle.z = bitbuf.ReadBitAngle(16);
return !bitbuf.IsOverflowed();
}
bool SVC_CrosshairAngle_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_CrosshairAngle* data)
{
bitbuf.WriteBitAngle(data->x, 16);
bitbuf.WriteBitAngle(data->y, 16);
bitbuf.WriteBitAngle(data->z, 16);
bitbuf.WriteBitAngle(data->angle.x, 16);
bitbuf.WriteBitAngle(data->angle.y, 16);
bitbuf.WriteBitAngle(data->angle.z, 16);
return !bitbuf.IsOverflowed();
}
@ -30,11 +31,7 @@ namespace NetHandlers
bool SVC_CrosshairAngle_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_CrosshairAngle* data)
{
jsonbuf.StartObject("svc_crosshairangle");
jsonbuf.StartObject("angle");
jsonbuf.WriteFloat("pitch", data->x);
jsonbuf.WriteFloat("yaw", data->y);
jsonbuf.WriteFloat("roll", data->z);
jsonbuf.EndObject();
DemoJsonWriter::WriteAngle(jsonbuf, "angle", data->angle);
jsonbuf.EndObject();
return true;
}
@ -44,9 +41,9 @@ namespace NetHandlers
const std::streamsize oldPrecision = out.precision();
out << "svc_CrosshairAngle:"
<< std::setprecision(1) << std::fixed
<< " (" << data->x
<< " " << data->y
<< " " << data->z << ")"
<< " (" << data->angle.x
<< " " << data->angle.y
<< " " << data->angle.z << ")"
<< std::setprecision(oldPrecision);
out.unsetf(std::ios_base::floatfield);
}

View File

@ -2,14 +2,13 @@
#pragma once
#include "nethandlers.h"
#include "sourcesdk/vector.h"
namespace NetMsg
{
struct SVC_CrosshairAngle
{
float x;
float y;
float z;
QAngle angle;
};
}

View File

@ -2,6 +2,7 @@
#include "svc_fixangle.h"
#include "base/bitfile.h"
#include "base/jsonfile.h"
#include "demofile/demojson.h"
#include <iomanip>
namespace NetHandlers
@ -9,18 +10,18 @@ namespace NetHandlers
bool SVC_FixAngle_BitRead_Internal(BitRead& bitbuf, SourceGameContext& context, NetMsg::SVC_FixAngle* data)
{
data->relative = bitbuf.ReadOneBit() != 0;
data->x = bitbuf.ReadBitAngle(16);
data->y = bitbuf.ReadBitAngle(16);
data->z = bitbuf.ReadBitAngle(16);
data->angle.x = bitbuf.ReadBitAngle(16);
data->angle.y = bitbuf.ReadBitAngle(16);
data->angle.z = bitbuf.ReadBitAngle(16);
return !bitbuf.IsOverflowed();
}
bool SVC_FixAngle_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_FixAngle* data)
{
bitbuf.WriteOneBit(data->relative);
bitbuf.WriteBitAngle(data->x, 16);
bitbuf.WriteBitAngle(data->y, 16);
bitbuf.WriteBitAngle(data->z, 16);
bitbuf.WriteBitAngle(data->angle.x, 16);
bitbuf.WriteBitAngle(data->angle.y, 16);
bitbuf.WriteBitAngle(data->angle.z, 16);
return !bitbuf.IsOverflowed();
}
@ -33,11 +34,7 @@ namespace NetHandlers
{
jsonbuf.StartObject("svc_fixangle");
jsonbuf.WriteBool("relative", data->relative);
jsonbuf.StartObject("angle");
jsonbuf.WriteFloat("pitch", data->x);
jsonbuf.WriteFloat("yaw", data->y);
jsonbuf.WriteFloat("roll", data->z);
jsonbuf.EndObject();
DemoJsonWriter::WriteAngle(jsonbuf, "angle", data->angle);
jsonbuf.EndObject();
return true;
}
@ -47,9 +44,9 @@ namespace NetHandlers
const std::streamsize oldPrecision = out.precision();
out << "svc_FixAngle: " << (data->relative ? "relative" : "absolute")
<< std::setprecision(1) << std::fixed
<< " " << data->x
<< " " << data->y
<< " " << data->z
<< " " << data->angle.x
<< " " << data->angle.y
<< " " << data->angle.z
<< std::setprecision(oldPrecision);
out.unsetf(std::ios_base::floatfield);
}

View File

@ -2,15 +2,14 @@
#pragma once
#include "nethandlers.h"
#include "sourcesdk/vector.h"
namespace NetMsg
{
struct SVC_FixAngle
{
bool relative;
float x;
float y;
float z;
QAngle angle;
};
}