Skip to content

Commit

Permalink
Added some inventory stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Bakkes committed Feb 6, 2019
1 parent e26d792 commit 2b8f5f4
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 14 deletions.
22 changes: 11 additions & 11 deletions PythonProject/wrapped.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,8 @@ BOOST_PYTHON_MODULE(bakkesmod)
def("SetbHasPitchedBack", &PlayerControllerWrapper::SetbHasPitchedBack).
def("GetbAllowAsymmetricalMute", &PlayerControllerWrapper::GetbAllowAsymmetricalMute).
def("SetbAllowAsymmetricalMute", &PlayerControllerWrapper::SetbAllowAsymmetricalMute).
def("GetbResetCamera", &PlayerControllerWrapper::GetbResetCamera).
def("SetbResetCamera", &PlayerControllerWrapper::SetbResetCamera).
//def("GetbResetCamera", &PlayerControllerWrapper::GetbResetCamera).
//def("SetbResetCamera", &PlayerControllerWrapper::SetbResetCamera).
def("GetTimeClientAckdAdjustSimTime", &PlayerControllerWrapper::GetTimeClientAckdAdjustSimTime).
def("SetTimeClientAckdAdjustSimTime", &PlayerControllerWrapper::SetTimeClientAckdAdjustSimTime).
def("GetReplicatedInputBufferSize", &PlayerControllerWrapper::GetReplicatedInputBufferSize).
Expand Down Expand Up @@ -588,10 +588,10 @@ BOOST_PYTHON_MODULE(bakkesmod)
def("SetLastInputs", &PlayerControllerWrapper::SetLastInputs).
def("GetPendingViewPRI", &PlayerControllerWrapper::GetPendingViewPRI).
def("SetPendingViewPRI", &PlayerControllerWrapper::SetPendingViewPRI).
def("GetLastInputPitch", &PlayerControllerWrapper::GetLastInputPitch).
def("SetLastInputPitch", &PlayerControllerWrapper::SetLastInputPitch).
def("GetLastInputYaw", &PlayerControllerWrapper::GetLastInputYaw).
def("SetLastInputYaw", &PlayerControllerWrapper::SetLastInputYaw).
//def("GetLastInputPitch", &PlayerControllerWrapper::GetLastInputPitch).
//def("SetLastInputPitch", &PlayerControllerWrapper::SetLastInputPitch).
//def("GetLastInputYaw", &PlayerControllerWrapper::GetLastInputYaw).
//def("SetLastInputYaw", &PlayerControllerWrapper::SetLastInputYaw).
def("GetMouseInputMax", &PlayerControllerWrapper::GetMouseInputMax).
def("SetMouseInputMax", &PlayerControllerWrapper::SetMouseInputMax).
def("GetPrimaryPlayerController", &PlayerControllerWrapper::GetPrimaryPlayerController).
Expand Down Expand Up @@ -646,8 +646,8 @@ BOOST_PYTHON_MODULE(bakkesmod)
def("SetbPredictionOnGround", &BallWrapper::SetbPredictionOnGround).
def("GetbCanBeAttached", &BallWrapper::GetbCanBeAttached).
def("SetbCanBeAttached", &BallWrapper::SetbCanBeAttached).
def("GetbNewFalling", &BallWrapper::GetbNewFalling).
def("SetbNewFalling", &BallWrapper::SetbNewFalling).
//def("GetbNewFalling", &BallWrapper::GetbNewFalling).
//def("SetbNewFalling", &BallWrapper::SetbNewFalling).
def("GetbItemFreeze", &BallWrapper::GetbItemFreeze).
def("SetbItemFreeze", &BallWrapper::SetbItemFreeze).
def("GetRadius", &BallWrapper::GetRadius).
Expand Down Expand Up @@ -684,7 +684,7 @@ BOOST_PYTHON_MODULE(bakkesmod)
def("SetPredictionTimestep", &BallWrapper::SetPredictionTimestep).
def("GetLastPredictionTime", &BallWrapper::GetLastPredictionTime).
def("SetLastPredictionTime", &BallWrapper::SetLastPredictionTime).
def("GetBallSloMoRadius", &BallWrapper::GetBallSloMoRadius).
/*def("GetBallSloMoRadius", &BallWrapper::GetBallSloMoRadius).
def("SetBallSloMoRadius", &BallWrapper::SetBallSloMoRadius).
def("GetBallSloMoDuration", &BallWrapper::GetBallSloMoDuration).
def("SetBallSloMoDuration", &BallWrapper::SetBallSloMoDuration).
Expand All @@ -697,7 +697,7 @@ BOOST_PYTHON_MODULE(bakkesmod)
def("GetBallSloMoDiffSpeed", &BallWrapper::GetBallSloMoDiffSpeed).
def("SetBallSloMoDiffSpeed", &BallWrapper::SetBallSloMoDiffSpeed).
def("GetBallTouchScore", &BallWrapper::GetBallTouchScore).
def("SetBallTouchScore", &BallWrapper::SetBallTouchScore).
def("SetBallTouchScore", &BallWrapper::SetBallTouchScore).*/
def("GetGroundForce", &BallWrapper::GetGroundForce).
def("SetGroundForce", &BallWrapper::SetGroundForce).
def("GetCurrentAffector", &BallWrapper::GetCurrentAffector).
Expand Down Expand Up @@ -1626,7 +1626,7 @@ BOOST_PYTHON_MODULE(bakkesmod)
def("SetPartyLeader", &PriWrapper::SetPartyLeader).
def("GetTotalXP", &PriWrapper::GetTotalXP).
def("SetTotalXP", &PriWrapper::SetTotalXP).
def("GetSanitizedPlayerName", &PriWrapper::GetSanitizedPlayerName).
//def("GetSanitizedPlayerName", &PriWrapper::GetSanitizedPlayerName).
def("GetDodgeInputThreshold", &PriWrapper::GetDodgeInputThreshold).
def("SetDodgeInputThreshold", &PriWrapper::SetDodgeInputThreshold).
def("GetSteeringSensitivity", &PriWrapper::GetSteeringSensitivity).
Expand Down
47 changes: 44 additions & 3 deletions RCONPlugin/RCONPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,15 @@ void RCONPlugin::on_message(server* s, websocketpp::connection_hdl hdl, message_
void RCONPlugin::run_server() {
try {
// Set logging settings
//ws_server.set_access_channels(websocketpp::log::alevel::all);
//ws_server.clear_access_channels(websocketpp::log::alevel::frame_payload);

ws_server.set_access_channels(websocketpp::log::alevel::all);
//ws_server.set_access_channels(websocketpp::log::alevel::access_core);
//ws_server.set_access_channels(websocketpp::log::alevel::app);
static std::ofstream wslog("ws.log.txt");
static std::ofstream wserlog("ws.errlog.txt");
ws_server.get_alog().set_ostream(&wslog);
ws_server.get_elog().set_ostream(&wserlog);
ws_server.get_alog().write(websocketpp::log::alevel::app, "ws_server constructor");
ws_server.get_elog().write(websocketpp::log::alevel::app, "ws_server constructor elog");
// Initialize Asio
ws_server.init_asio();

Expand Down Expand Up @@ -133,7 +139,42 @@ void RCONPlugin::onLoad()
}
}, "Sends text to all connected clients. Usage: sendback abc def ghi \"hij klm\"", PERMISSION_ALL);

cvarManager->registerNotifier("ws_inventory", [this](vector<string> commands) {
if (commands.size() < 3)
return;
cvarManager->log("Sending invent");
for (auth_iter iterator = auths.begin(); iterator != auths.end(); iterator++)
{
if (is_authenticated(iterator->first) && iterator->first.get()->get_state() == websocketpp::session::state::open)
{

std::string str = "invent_dump";
for (int i = 1; i < 3; i++)
{
str += " \"" + commands.at(i) + "\"";
}
cvarManager->executeCommand(str);
std::string format = commands.at(2).compare("csv") == 0 ? "csv" : "json"; //Dont want any path injection stuff
std::ifstream ifs("./bakkesmod/data/inventory." + format);
std::string content((std::istreambuf_iterator<char>(ifs)),
(std::istreambuf_iterator<char>()));


string::size_type pos = 0; // Must initialize
std::stringstream a;
a << std::endl;
std::string endl = a.str();
while ((pos = content.find(endl, pos)) != string::npos)
{
content.erase(pos, endl.size());
}
auto ec = iterator->first->send(content + "\n", websocketpp::frame::opcode::binary);

cvarManager->log(ec.message());
}
}

}, "Sends text to all connected clients. Usage: sendback abc def ghi \"hij klm\"", PERMISSION_ALL);
//thread t(run_server);
run_server();
//ws_server.run();
Expand Down

0 comments on commit 2b8f5f4

Please sign in to comment.