Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jice1001/server
Browse files Browse the repository at this point in the history
  • Loading branch information
jice1001 committed Aug 18, 2016
2 parents 6c77193 + 0bf65a4 commit 6908399
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 8 deletions.
17 changes: 15 additions & 2 deletions config/server/server_misc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"agent_num" : 1, //平台编号,比如37wan编号为1,4399为2,生成角色id,帮派id时候用
"server_num" : 1, //服务器编号,比如1服编号为1,生成角色id,帮派id时候用
"aoi_broadcast_interval" : 10, //aoi场景广播间隔,时间单位:毫秒
"aoi_radius" : 10, //aoi范围单位
"game_db_struct_path" : "config/struct/game_struct.xml",
"log_db_struct_path" : "config/struct/log_struct.xml",
"msg_struct_path" : "config/struct/msg_struct.xml",
Expand Down Expand Up @@ -42,5 +43,17 @@
"password" : "123456",
"dbname" : "log",
"dbpoolname" : "log_pool"
}
}
},
//gate服务器列表
"gate_server_list" : {
"0" : {
"ip" : "127.0.0.1",
"port" : 8500
},
"1" : {
"ip" : "127.0.0.1",
"port" : 8501
}
}
}

2 changes: 2 additions & 0 deletions game_server/Game_Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

#include "Game_Scene.h"
#include "Log.h"

Game_Scene::Game_Scene(int type, SCENE_ID id):
scence_type_(type),
Expand Down Expand Up @@ -41,6 +42,7 @@ int Game_Scene::load_scene_map(){
}

int Game_Scene::on_enter_scene(Scene_Entity *entity){
//LOG_INFO("Player enter scene %d", scene_id_);
entities_map_[entity->entity_id()] = entity;
entity->scene(this);
aoi_manager_->on_enter_aoi(entity->aoi_entity());
Expand Down
3 changes: 2 additions & 1 deletion game_server/Scene_Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
#include "Scene_Manager.h"
#include "Game_Manager.h"
#include "Aoi_Entity.h"
#include "Server_Config.h"

Scene_Entity::Scene_Entity(Game_Player *game_player):
entity_id_(1),
player_(game_player),
pos_(0, 0, 0),
opos_(0, 0, 0),
scene_(0),
radius_(3),
radius_(SERVER_CONFIG->server_misc()["aoi_radius"].asInt()),
aoi_entity_(new Aoi_Entity(this)),
need_sync_(false),
extra_info_()
Expand Down
6 changes: 5 additions & 1 deletion js/game_player.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ Game_Player.prototype.load_player_data = function(gate_cid, player_cid, obj) {
game_close_client(gate_cid, player_cid, Error_Code.ERROR_CLIENT_PARAM);
return;
}
if(this.player_info.last_scene == 0)
this.player_info.last_scene = 11001;
print("JS READY TO ENTER SCENE");
this.cplayer.enter_scene(this.player_info.last_scene, this.player_info.last_pos.x, this.player_info.last_pos.y, this.player_info.last_pos.z);
this.cplayer.set_aoi_info();
this.set_aoi_info();

this.sync_login_to_client();
this.sync_login_to_master();
Expand All @@ -48,6 +51,7 @@ Game_Player.prototype.save_player_data = function() {
this.player_info.logout_time = util.now_sec();
this.sync_player_data_to_db(true);
this.sync_logout_to_log();
this.cplayer.leave_scene();

logout_map.set(this.player_info.account, this.player_info.logout_time);
game_player_cid_map.delete(this.gate_cid * 10000 + this.player_cid);
Expand Down
17 changes: 13 additions & 4 deletions v8/Player_Wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,22 @@ void enter_scene(const FunctionCallbackInfo<Value>& args) {
float z = args[3]->NumberValue(args.GetIsolate()->GetCurrentContext()).FromMaybe(0);
player->scene_entity()->pos().set_position(x, y, z);
Game_Scene *scene = SCENE_MANAGER->get_scene(scene_id);
if(scene != NULL) {
scene->on_enter_scene(player->scene_entity());
if(scene == NULL) {
LOG_ERROR("Scene %d not exist!", scene_id);
return;
}
scene->on_enter_scene(player->scene_entity());
}

void leave_scene(const FunctionCallbackInfo<Value>& args) {

Game_Player *player = unwrap_game_player(args.Holder());
if(!player) {
return;
}
Game_Scene *scene = player->scene_entity()->scene();
if(scene != NULL){
scene->on_leave_scene(player->scene_entity());
}
}

void move_to_point(const FunctionCallbackInfo<Value>& args) {
Expand All @@ -93,7 +102,7 @@ void move_to_point(const FunctionCallbackInfo<Value>& args) {

void set_aoi_info(const FunctionCallbackInfo<Value>& args) {
if (args.Length() != 1) {
LOG_ERROR("move_to_point args error, length: %d\n", args.Length());
LOG_ERROR("set_aoi_info args error, length: %d\n", args.Length());
return;
}
Game_Player *player = unwrap_game_player(args.Holder());
Expand Down
2 changes: 2 additions & 0 deletions v8/V8_Wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ Local<Context> Create_Context(Isolate* isolate) {
FunctionTemplate::New(isolate, game_player_link_close)) ;
game_player_template->Set(String::NewFromUtf8(isolate, "enter_scene", NewStringType::kNormal).ToLocalChecked(),
FunctionTemplate::New(isolate, enter_scene)) ;
game_player_template->Set(String::NewFromUtf8(isolate, "leave_scene", NewStringType::kNormal).ToLocalChecked(),
FunctionTemplate::New(isolate, leave_scene)) ;
game_player_template->Set(String::NewFromUtf8(isolate, "move_to_point", NewStringType::kNormal).ToLocalChecked(),
FunctionTemplate::New(isolate, move_to_point)) ;
game_player_template->Set(String::NewFromUtf8(isolate, "set_aoi_info", NewStringType::kNormal).ToLocalChecked(),
Expand Down

0 comments on commit 6908399

Please sign in to comment.