Skip to content

Commit 5ca8bb5

Browse files
committed
A few little changes
1 parent d00de7a commit 5ca8bb5

4 files changed

Lines changed: 15 additions & 11 deletions

File tree

‎ServerAPI/Example/DebugGame.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ void DebugGame::onJoin(Client *cli){
6060

6161
PadConfig DebugGame::getDefaultControls(){
6262
PadConfig conf;
63-
ButtonControl *btn1 = new ButtonControl(.5, .5, .25, 0, BUTTON_A);
64-
DPadControl *dpad = new DPadControl(0, 0, .2, 1);
63+
ButtonControl *btn1 = new ButtonControl(.2, .2, .1, 0, BUTTON_A);
64+
DPadControl *dpad = new DPadControl(.5, .75, .2, 1);
6565

66-
conf.controls.push_back(btn1);
67-
conf.controls.push_back(dpad);
66+
conf.addControl(btn1);
67+
conf.addControl(dpad);
6868

6969
return conf;
7070
}
@@ -75,5 +75,5 @@ void DebugGame::onDisconnect(Client *cli){
7575

7676
void DebugGame::onPadUpdate(Client *cli, PadUpdateObject update){
7777
//Player controller action
78-
printf("Player did something with controll %d\n", update.controlid);
78+
printf("Player did something with control %d\n", update.controlid);
7979
}

‎ServerAPI/PlayPhone/Request.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ bool PadUpdateObject::parseJSON(Value &v){
250250
action = v["action"].GetInt();
251251
controlid = v["controlid"].GetInt();
252252
Value& pos = v["position"];
253-
x = pos["x"].GetInt();
254-
y = pos["y"].GetInt();
253+
x = pos["x"].GetDouble();
254+
y = pos["y"].GetDouble();
255255

256256
return true;
257257
} catch (exception ex) {
@@ -274,7 +274,7 @@ Value& ButtonControl::serializeJSON(Document::AllocatorType &a){
274274
}
275275

276276
DPadControl::DPadControl(float x, float y, float w, int _controlid){
277-
this->type = BUTTON;
277+
this->type = DPAD;
278278
frame.set(x, y, w, w);
279279
controlID = _controlid;
280280
}

‎ServerAPI/PlayPhone/Request.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ namespace openpad {
116116
public:
117117
bool parseJSON(Value& v);
118118

119-
int x,y,controlid,action;
119+
int controlid,action;
120+
float x,y;
120121
};
121122

122123
class ButtonControl : public ControlObject{

‎ServerAPI/PlayPhone/Server.cpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,11 @@ Response Server::handleRequest(Request &r, Client* cli){
204204
Response resp(200,"OK");
205205
if(cli->hasJoined){
206206
PadUpdateObject update;
207-
update.parseJSON(*r.root);
208-
207+
if(update.parseJSON(*r.root)){
208+
handler.onPadUpdate(cli, update);
209+
}else{
210+
resp.statusMsg = "Bad padupdate JSON";
211+
}
209212
}else{
210213
Document d;
211214
Value& obj = resp.serializeJSON(d.GetAllocator());

0 commit comments

Comments
 (0)