From 5eb4336781883f1367d02aa76871bc6e1d76eab1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Feb 2019 19:17:41 -1100 Subject: [PATCH] Set name roc --- src/cc/cclib.cpp | 4 ++++ src/cc/rogue_rpc.cpp | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index f5a3d092e..c13f55ce4 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -63,6 +63,7 @@ CClib_methods[] = { (char *)"rogue", (char *)"playerinfo", (char *)"playertxid", 1, 1, 'I', EVAL_ROGUE }, { (char *)"rogue", (char *)"players", (char *)"", 0, 0, 'D', EVAL_ROGUE }, { (char *)"rogue", (char *)"games", (char *)"", 0, 0, 'F', EVAL_ROGUE }, + { (char *)"rogue", (char *)"setname", (char *)"pname", 1, 1, 'N', EVAL_ROGUE }, #else { (char *)"sudoku", (char *)"gen", (char *)"", 0, 0, 'G', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, @@ -87,6 +88,7 @@ UniValue rogue_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #else bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); @@ -122,6 +124,8 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) return(rogue_players(txfee,cp,params)); else if ( strcmp(method,"games") == 0 ) return(rogue_games(txfee,cp,params)); + else if ( strcmp(method,"setname") == 0 ) + return(rogue_setname(txfee,cp,params)); else { result.push_back(Pair("result","error")); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 7fdc4f53a..4f287333e 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1094,6 +1094,27 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } +UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); char *namestr = 0; + rogue_univalue(result,"setname",-1,-1); + if ( (params= cclib_reparse(&n,params)) != 0 ) + { + if ( n > 0 ) + { + if ( (namestr= jstri(params,0)) != 0 ) + { + result.push_back(Pair("result","success")); + result.push_back(Pair("name",namestr)); + return(result); + } + } + } + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt get name")); + return(result); +} + bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { return(true);