def notify_enter_list(self, notify_list, cid, x, y): #print "notify_enter_list %s,%s,%s,%s"%(notify_list,cid,x,y); if len(notify_list) <= 0: return dId_list = [] for i in notify_list: dId = self._getdidbycid(i) if dId != None: dId_list.append(dId) cinfo = self.characterinfo_map[cid] shape = cinfo["shape"] x = cinfo["x"] y = cinfo["y"] name = cinfo["name"] #print "%s %s %s %s %s %s"%(shape,x,y,name,type(name),dId_list); data = {} data['id'] = cid data['shape'] = shape data['x'] = x data['y'] = y data['desc'] = "" data['name'] = name buf = netutil.s2c_data2bufbycmd(S2C_MAP_ADDPLAYER, data) GlobalObject().remote['gate'].callRemote("pushObject", S2C_MAP_ADDPLAYER, buf, dId_list) return
def _send2client(self, ud): cmd = ud[0] dId = ud[1] data = ud[2] buf = netutil.s2c_data2bufbycmd(cmd, data) GlobalObject().remote['gate'].callRemote("pushObject", cmd, buf, [dId]) return
def notify_region_2_c(self, cid, c_list): #print "notify_region_2_c %s %s"%(cid,c_list); dId = self._getdidbycid(cid) if dId == None: print "notify_region_2_c fatal error %d" % (cid) return for i in c_list: #print "notify_region_2_c %d"%(i); if self.characterinfo_map.has_key(i): cinfo = self.characterinfo_map[i] shape = cinfo["shape"] x = cinfo["x"] y = cinfo["y"] name = cinfo["name"] desc = "" data = {} data['id'] = i data['shape'] = shape data['name'] = name data['desc'] = desc data['x'] = x data['y'] = y #print "notify_region_2_c send %s %s %s %s %s %s"%(dId,i,shape,name,x,y); buf = netutil.s2c_data2bufbycmd(S2C_MAP_ADDPLAYER, data) GlobalObject().remote['gate'].callRemote( "pushObject", S2C_MAP_ADDPLAYER, buf, [dId]) return
def on_chat(self, ud): dId = ud["dId"] cId = ud["cId"] data = ud["data"] ch = data["ch"] msg = data["msg"] #todo print "on_chat %d %s" % (cId, msg) c_data = memmode.tb_character_admin.getObj(cId) if not c_data: log.msg('chat_main on_chat fatal err %d' % (cId)) return c_info = c_data.get('data') data = {} data['ch'] = ch data['srvid'] = 0 data['pid'] = cId data['shape'] = c_info["figure"] data['vip'] = 0 data['name'] = c_info["nickname"] data['msg'] = msg cmd = S2C_CHAT buf = netutil.s2c_data2bufbycmd(cmd, data) exclude_list = [] GlobalObject().remote['gate'].callRemote("pushObjectOthers", cmd, buf, exclude_list) return
def _send2clientbycid(self, ud): cmd = ud[0] cId = ud[1] dId = self._getdidbycid(cId) if dId == None: log.err("_send2clientbycid err:%s %s" % (cId, ud)) return data = ud[2] buf = netutil.s2c_data2bufbycmd(cmd, data) GlobalObject().remote['gate'].callRemote("pushObject", cmd, buf, [dId]) return
def _send2clientbycidlist(self, cmd, cid_list, data): print "combat_main _send2clientbycidlist %x %s" % (cmd, cid_list) dId_list = [] for i in cid_list: dId = self._getdidbycid(i) if dId != None: dId_list.append(dId) if len(dId_list) <= 0: return buf = netutil.s2c_data2bufbycmd(cmd, data) GlobalObject().remote['gate'].callRemote("pushObject", cmd, buf, dId_list) return
def notify_quit_list(self, notify_list, cid): #print "notify_quit_list %s,%s"%(notify_list,cid); if len(notify_list) <= 0: return dId_list = [] for i in notify_list: dId = self._getdidbycid(i) if dId != None: dId_list.append(dId) #print "%s"%(dId_list); data = {} data['id'] = cid buf = netutil.s2c_data2bufbycmd(S2C_MAP_DEL, data) GlobalObject().remote['gate'].callRemote("pushObject", S2C_MAP_DEL, buf, dId_list) return
def notify_enter_new_region(self, cid, x, y, rw, rh): #print "notify_enter_new_region %s,%s,%s,%s,%s"%(cid,x,y,rw,rh); dId = self._getdidbycid(cid) if dId == None: print "notify_region_2_c fatal error %d" % (cid) return data = {} data['rw'] = rw data['rh'] = rh data['x'] = x data['y'] = y buf = netutil.s2c_data2bufbycmd(S2C_MAP_REGIONCHANGE, data) GlobalObject().remote['gate'].callRemote("pushObject", S2C_MAP_REGIONCHANGE, buf, [dId]) return
def on_login(self, ud): dId = ud["dId"] cId = ud["cId"] self.character_map[cId] = dId c_data = memmode.tb_character_admin.getObj(cId) if not c_data: log.msg('scene_main on_login fatal err %d' % (cId)) return c_info = c_data.get('data') sid = c_info['town'] px = c_info['position_x'] py = c_info['position_y'] shape = c_info['figure'] name = c_info['nickname'] scene_obj = self.smgr.get_scene_obj(sid) if not scene_obj: log.msg('scene_main on_login have not this scene %d,%d' % (cId, sid)) return self.characterinfo_map[cId] = { 'sid': sid, 'x': px, 'y': py, 'shape': shape, 'name': name } data = {} data['id'] = cId data['scid'] = sid data['scsid'] = sid data['resid'] = scene_obj.resid data['x'] = px data['y'] = py data['scname'] = scene_obj.name buf = netutil.s2c_data2bufbycmd(S2C_HERO_ENTERSCENE, data) GlobalObject().remote['gate'].callRemote("pushObject", S2C_HERO_ENTERSCENE, buf, [dId]) self.smgr.enter(cId, sid, px, py) return
def notify_move_list(self, notify_list, cid, x, y): #print "notify_move_list %s,%s,%s,%s"%(notify_list,cid,x,y); if len(notify_list) <= 0: return dId_list = [] for i in notify_list: dId = self._getdidbycid(i) if dId != None: dId_list.append(dId) #print "%s %s %s %s"%(cid,x,y,dId_list); data = {} data['id'] = cid data['x'] = x data['y'] = y data['dx'] = x data['dy'] = y buf = netutil.s2c_data2bufbycmd(S2C_MAP_TRACK, data) GlobalObject().remote['gate'].callRemote("pushObject", S2C_MAP_TRACK, buf, dId_list) return