Skip to content

Commit

Permalink
Refactor|World: Preparing ClientServerWorld for splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jan 14, 2020
1 parent ee1a908 commit 2328fa0
Show file tree
Hide file tree
Showing 7 changed files with 447 additions and 370 deletions.
12 changes: 6 additions & 6 deletions doomsday/apps/client/include/world/clientserverworld.h
Expand Up @@ -116,9 +116,12 @@ class ClientServerWorld : public world::World
*/
timespan_t time() const;

void tick(timespan_t elapsed);

#ifdef __CLIENT__

bool allowAdvanceTime() const override;

void tick(timespan_t) override;

/**
* To be called at the beginning of a render frame, so that we can prepare for
* drawing view(s) of the current map.
Expand All @@ -130,12 +133,9 @@ class ClientServerWorld : public world::World
* that must be completed after view(s) have been drawn.
*/
void endFrame();

#endif // __CLIENT__

public:
/// Scripting helper: get pointer to current instance mobj_t based on the script callstack.
static mobj_t &contextMobj(const de::Context &);

private:
DE_PRIVATE(d)
};
Expand Down
20 changes: 10 additions & 10 deletions doomsday/apps/client/src/world/base/bindings_world.cpp
Expand Up @@ -37,7 +37,7 @@ namespace world {

static Value *Function_Thing_AddMom(Context &ctx, const Function::ArgumentValues &args)
{
mobj_t & mo = ClientServerWorld::contextMobj(ctx);
mobj_t & mo = World::contextMobj(ctx);
const auto delta = vectorFromValue<Vec3d>(*args.at(0));
mo.mom[VX] += delta.x;
mo.mom[VY] += delta.y;
Expand All @@ -47,27 +47,27 @@ static Value *Function_Thing_AddMom(Context &ctx, const Function::ArgumentValues

static Value *Function_Thing_Id(Context &ctx, const Function::ArgumentValues &)
{
return new NumberValue(ClientServerWorld::contextMobj(ctx).thinker.id);
return new NumberValue(World::contextMobj(ctx).thinker.id);
}

static Value *Function_Thing_Health(Context &ctx, const Function::ArgumentValues &)
{
return new NumberValue(ClientServerWorld::contextMobj(ctx).health);
return new NumberValue(World::contextMobj(ctx).health);
}

static Value *Function_Thing_Height(Context &ctx, const Function::ArgumentValues &)
{
return new NumberValue(ClientServerWorld::contextMobj(ctx).height);
return new NumberValue(World::contextMobj(ctx).height);
}

static Value *Function_Thing_Mom(Context &ctx, const Function::ArgumentValues &)
{
return new ArrayValue(Vec3d(ClientServerWorld::contextMobj(ctx).mom));
return new ArrayValue(Vec3d(World::contextMobj(ctx).mom));
}

static Value *Function_Thing_StartSound(Context &ctx, const Function::ArgumentValues &args)
{
const mobj_t &mo = ClientServerWorld::contextMobj(ctx);
const mobj_t &mo = World::contextMobj(ctx);
const int sound = DED_Definitions()->getSoundNum(args.at(0)->asText());
const float volume = float(args.at(1)->asNumber());
if (sound >= 0)
Expand All @@ -83,7 +83,7 @@ static Value *Function_Thing_StartSound(Context &ctx, const Function::ArgumentVa

static Value *Function_Thing_Player(Context &ctx, const Function::ArgumentValues &)
{
const mobj_t &mo = ClientServerWorld::contextMobj(ctx);
const mobj_t &mo = World::contextMobj(ctx);
if (mo.dPlayer)
{
auto &plrs = DoomsdayApp::players();
Expand All @@ -94,12 +94,12 @@ static Value *Function_Thing_Player(Context &ctx, const Function::ArgumentValues

static Value *Function_Thing_Pos(Context &ctx, const Function::ArgumentValues &)
{
return new ArrayValue(Vec3d(ClientServerWorld::contextMobj(ctx).origin));
return new ArrayValue(Vec3d(World::contextMobj(ctx).origin));
}

static Value *Function_Thing_Recoil(Context &ctx, const Function::ArgumentValues &args)
{
mobj_t & mo = ClientServerWorld::contextMobj(ctx);
mobj_t & mo = World::contextMobj(ctx);
const double force = args.at(0)->asNumber();

const angle_t angle = mo.angle + ANG180;
Expand All @@ -113,7 +113,7 @@ static Value *Function_Thing_Recoil(Context &ctx, const Function::ArgumentValues

static Value *Function_Thing_Type(Context &ctx, const Function::ArgumentValues &)
{
return new NumberValue(ClientServerWorld::contextMobj(ctx).type);
return new NumberValue(World::contextMobj(ctx).type);
}

//-------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 2328fa0

Please sign in to comment.