Player * rbtF_player_init( rabbit * r, int account ) { struct Player * ply = RMALLOC(r, struct Player, 1); ply->account = account; ply->pid = -1; ply->curr_gid = -1; ply->curr_group_next = NULL; gettimeofday(&ply->come_tm, NULL); setpvalue(rbtH_setnum(r, G(r)->accounts, account), ply); rbtStat_init(r, &ply->stat); list_init(&ply->player_list); ply->world_msg_tm = -1000; return ply; }
void luaV_concat (lua_State *L, int total, int last) { do { StkId top = L->base + last + 1; int n = 2; /* number of elements handled in this pass (at least 2) */ if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { setpvalue(L->top, (void *)(ptrdiff_t)(last - 1)); /* for luaV_resume */ L->top++; if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) luaG_concaterror(L, top-2, top-1); L->top--; } else if (tsvalue(top-1)->len == 0) /* second op is empty? */ (void)tostring(L, top - 2); /* result is first op (as string) */ else { /* at least two string values; get as many as possible */ size_t tl = tsvalue(top-1)->len; char *buffer; int i; /* collect total length */ for (n = 1; n < total && tostring(L, top-n-1); n++) { size_t l = tsvalue(top-n-1)->len; if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow"); tl += l; } buffer = luaZ_openspace(L, &G(L)->buff, tl); tl = 0; for (i=n; i>0; i--) { /* concat all strings */ size_t l = tsvalue(top-i)->len; memcpy(buffer+tl, svalue(top-i), l); tl += l; } setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl)); } total -= n-1; /* got `n' strings to create 1 new */ last -= n-1; } while (total > 1); /* repeat until only 1 result left */ }
void rbtF_player_enter_group(rabbit * r, Player * player, int gid) { if(player->curr_gid > 0) { rbtF_player_leave_group(r, player); } player->curr_gid = gid; struct LogicalServer * serv = rbtF_get_serv_by_zone(r, player->zone_id); if(!serv) { kLOG(r, player->pid, "玩家(%d)进组(%x),没有服务器?\n", player->pid, player->zone_id); return; } TValue * tv = cast(TValue *, rbtH_getnum(r, serv->groups, gid)); if(!ttisp(tv)) { player->curr_group_next = NULL; setpvalue(rbtH_setnum(r, serv->groups, gid), player); return; } player->curr_group_next = cast(Player *, pvalue(tv)); setpvalue(tv, cast(GCObject *, player)); }
LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { lua_lock(L); setpvalue(L->top, p); api_incr_top(L); lua_unlock(L); }
LUA_API void LUA_pushlightuserdata (LUA_State *L, void *p) { LUA_lock(L); setpvalue(L->top, p); api_incr_top(L); LUA_unlock(L); }