Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #57

Merged
merged 9 commits into from
Sep 25, 2024
Merged

Dev #57

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
/src/lua/proto/code.lua
/src/lua/proto/enum.lua
/src/lua/struct/excel.lua
/src/pycli/proto
/pycli/proto
# Codeblocks
*.layout
*.depend
Expand Down Expand Up @@ -89,4 +89,4 @@ src/proto/msg_id.proto
src/struct/msg_id.h
src/struct/msg_id.cc
src/proto/n_msg_id.proto
src/pycli/login.cookie
pycli/login.cookie
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "res"]
path = res
url = https://github.com/pwnsky/squick-res.git
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ add_definitions(-DSQUICK_LOG_OPEN_STDOUT) # Log stdout print
add_subdirectory(src/struct)
add_subdirectory(src/squick)
add_subdirectory(src/node)
add_subdirectory(src/tools/sqkcli)
add_subdirectory(src/tutorial)


Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions pycli/login.cookie
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#LWP-Cookies-2.0
Set-Cookie3: Session="eyJhY2NvdW50IjoicHljbGlfMSIsImFjY291bnRfaWQiOiIwLTE3MjcyNjg0MTE3NjQwMDAwMDAiLCJsb2dpbl90aW1lIjoxNzI3MjY4NDExLCJ0b2tlbiI6ImYyZTAyMGI2ZWY1YjRjMTQxOGU5MWU2NTE1NjRkZmE5MzMxNzQwZjAyN2ZhNTJkODY0NzU5ZjYxYTUxNDc4OTEifQ=="; path="/"; domain="127.0.0.1"; path_spec; expires="2024-10-09 12:46:51Z"; version=0
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions res
Submodule res added at 872ffa
Binary file removed resource/excel/Group.xlsx
Binary file not shown.
Binary file removed resource/excel/Object.xlsx
Binary file not shown.
Binary file removed resource/excel/Player.xlsx
Binary file not shown.
Binary file removed resource/excel/Scene.xlsx
Binary file not shown.
Binary file removed resource/excel/common/IObject.xlsx
Binary file not shown.
Binary file removed resource/excel/example/Property.xlsx
Binary file not shown.
Binary file removed resource/excel/example/Record.xlsx
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 33 additions & 3 deletions script/run_lua.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#! /bin/python
import requests
import json

Expand All @@ -15,19 +16,48 @@
Env
ModuleMgr
'''

print(global_env)
print('Example: print_t(Env)')
example1='''
Example 1: print env info

print_t(Env)
:r
'''
print(example1)

example2='''
Example2: print the config data

local ta = Squick:GetConfig(Excel.Scene.ThisName)
return print_t(ta)
:r
'''
print(example2)

print("input :r to run")
print("input :q to quit")

def check_input(user_input):
real_inpurt = ''
if 'return' not in user_input:
real_input = 'return ' + user_input
else:
real_input = user_input
return real_input


while True:
user_input = input("lua: ")
data['script'] = check_input(user_input)
script = ""
while True:
user_input = input()
if user_input == ':r':
break
if user_input == ':q':
exit()
script += user_input + '\n'
print(script)
data['script'] = check_input(script)
#print(user_input)
response = requests.post(url, data=json.dumps(data))
output = json.loads(response.text)
Expand Down
191 changes: 189 additions & 2 deletions src/proto/game.proto → src/lua/proto/proto.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,61 @@
// 描述: 房间、匹配、副本
----------------------------------------------------------------------------------
-- don't edit it, generated from .proto files by tools
----------------------------------------------------------------------------------

proto_code = [[
// 描述: 基础定义
// 使用: 服务器, 客户端
syntax = "proto3";
package rpc;
import "base.proto";

message Vector2 {
float x = 1;
float y = 2;
}

message Vector3 {
float x = 1;
float y = 2;
float z = 3;
}

message Vector4 {
float x = 1;
float y = 2;
float z = 3;
float w = 4;
}

enum ErrorCode {
ErrCommonSucc = 0;
ErrCommonFaild = 1;
}


message PlayerData {
string account = 1;
string account_id = 2;
uint64 uid = 3;
string name = 4;
int32 level = 5;
string ip = 6;
int32 area = 7;
int32 created_time = 8;
int32 last_login_time = 9;
int32 last_offline_time = 10;
string platform = 11;
}

message OnlineTable {
int64 uid = 1;
}

message PlayerTable {
int64 uid = 1; // index
PlayerData data = 2;
}
// 描述: 房间、匹配、副本
// 使用: 服务器, 客户端

// 20000 ~ 22000
enum GameBaseRPC {
Expand Down Expand Up @@ -183,3 +236,137 @@ message AckRoomGamePlayStart {
message ReqRoomCreateRobot { int32 amount = 1; }

message AckRoomCreateRobot { int32 code = 1; }
// Generated by the res/Tools/proto/gen_msgid.py. DO NOT EDIT!
// Update time: 2024-09-25 19:07:51

enum MsgId {
MsgIdZero = 0;
IdReqConnectProxy = 8003; // message: rpc.ReqConnectProxy desc: Request to connect the proxy
IdAckConnectProxy = 8004; // message: rpc.AckConnectProxy desc: Request to connect the proxy response
IdReqDisconnectProxy = 8005; // message: rpc.ReqDisconnectProxy desc:
IdAckDisconnectProxy = 8007; // message: rpc.AckDisconnectProxy desc:
IdReqHeartBeat = 8008; // message: rpc.ReqHeartBeat desc:
IdAckHeartBeat = 8009; // message: rpc.AckHeartBeat desc:
IdAckKickOff = 8010; // message: rpc.AckKickOff desc:
IdReqPlayerEnter = 12004; // message: rpc.ReqPlayerEnter desc:
IdAckPlayerEnter = 12005; // message: rpc.AckPlayerEnter desc:
IdReqPlayerLeave = 12006; // message: rpc.ReqPlayerLeave desc:
IdAckPlayerLeave = 12007; // message: rpc.AckPlayerLeave desc:
IdReqPlayerData = 12008; // message: rpc.ReqPlayerData desc:
IdAckPlayerData = 12009; // message: rpc.AckPlayerData desc:
IdTReqConfig = 14900; // message: rpc.TReqConfig desc:
IdTAckConfig = 14901; // message: rpc.TAckConfig desc:
IdTReqDb = 14902; // message: rpc.TReqDb desc:
IdTAckDb = 14903; // message: rpc.TAckDb desc:
}// 描述: 玩家RPC
// 使用: 服务器,客户端

// PlayerRPC 12000 ~ 15000

message ReqPlayerEnter { // msg_id=12004;
string account = 1;
string account_id = 2;
string ip = 3;
int32 proxy_node = 4;
int32 login_node = 5;
int32 protocol = 6;
int32 area = 7;
int32 platform = 8;
int64 proxy_sock = 9;
}

message AckPlayerEnter { // msg_id=12005;
int32 code = 1;
int64 proxy_sock = 2;
PlayerData data = 3;
}

message ReqPlayerLeave { // msg_id=12006;
}

message AckPlayerLeave { // msg_id=12007;
}

message ReqPlayerData { // msg_id=12008;
}

message AckPlayerData { // msg_id=12009;
int32 code = 1;
PlayerData data = 2;
}


message TReqConfig { // msg_id=14900;
int32 index = 1;
int64 req_time = 2;
bytes data = 3;
}

message TAckConfig { // msg_id=14901;
int32 index = 1;
int64 req_time = 2;
bytes data = 3;
}

message TReqDb { // msg_id=14902;
int32 index = 1;
int64 req_time = 2;
bytes data = 3;
}

message TAckDb { // msg_id=14903;
int32 index = 1;
int64 req_time = 2;
bytes data = 3;
}// Desc: 8000 ~ 10000

message ReqConnectProxy { // msg_id=8003; desc=Request to connect the proxy;
string account_id = 1;
string key = 2;
int32 login_node = 3;
uint64 signatrue = 4;
}

message AckConnectProxy { // msg_id=8004; desc=Request to connect the proxy response;
int32 code = 1;
}

message ReqDisconnectProxy { // msg_id=8005;
}
message AckDisconnectProxy { // msg_id=8007;
int32 code = 1;
}

message ReqHeartBeat { // msg_id=8008;
int32 index = 1;
}

message AckHeartBeat { // msg_id=8009;
int32 index = 1;
}

message AckKickOff { // msg_id=8010;
int64 time = 1;
}// 各服务器之间的通信RPC

// Servers RPC 50000 ~ 50200
enum TestRPC {
TEST_RPC_NONE = 0;

REQ_TEST_PROXY = 50000;
ACK_TEST_PROXY = 50001;

REQ_TEST_GAMEPLAY = 50002;
ACK_TEST_GAMEPLAY = 50003;

REQ_TEST_PLAYER_DATA_READ = 50004;
REQ_TEST_PLAYER_DATA_WRITE = 50005;
}

message Test {
int32 index = 1;
int64 req_time = 2;
bytes data = 3;
}

]]
11 changes: 10 additions & 1 deletion src/lua/test/pb.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,13 @@ function Test1()
PrintTable(test_tbl);
end

Test1()
function Test2()
print("create a blank proto struct to lua table")
local test_tbl = Squick:GetProtoTable("rpc.PlayerData")
PrintTable(test_tbl)
print("Json encode:")
print(Json.encode(test_tbl))
end

--Test1()
Test2()
6 changes: 3 additions & 3 deletions src/node/proxy/logic/logic_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,16 @@ bool LogicModule::SendToPlayer(uint64_t uid, const int msg_id, const string &dat
try {
auto pInfo = GetPlayerConnInfoByUID(uid);
if (pInfo == nullptr) {
throw;
throw std::runtime_error("pInfo is nullptr");
}
if (pInfo->protocol_type == ProtocolType::Tcp) {
m_net_->SendMsg(msg_id, data, pInfo->sock);
} else if (pInfo->protocol_type == ProtocolType::WS) {
m_ws_->SendMsg(msg_id, data.data(), data.size(), pInfo->sock);
}
ret = true;
} catch (...) {
LOG_ERROR("Send to player failed, uid<%v>", uid);
} catch (const std::runtime_error &e) {
LOG_ERROR("Send to player failed, uid<%v>, what<%v>", uid, e.what());
}
return ret;
}
Expand Down
41 changes: 0 additions & 41 deletions src/proto/base.proto

This file was deleted.

2 changes: 0 additions & 2 deletions src/proto/n_backstage.proto

This file was deleted.

Loading
Loading