nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
main.cc
Go to the documentation of this file.
1#include <imgui.h>
2#include <raylib.h>
3#include <raymath.h>
4
5#include <algorithm>
6#include <cstdint>
7#include <ctime>
8#include <iostream>
9#include <map>
10#include <memory>
11#include <optional>
12#include <span>
13#include <string>
14#include <string_view>
15#include <utility>
16#include <vector>
17
18#include "absl/status/statusor.h"
19#include "absl/strings/str_cat.h"
20#include "absl/strings/substitute.h"
21#include "client/ambience.h"
22#include "client/animator.h"
23#include "client/atmosphere.h"
24#include "client/audio.h"
25#include "client/bag_window.h"
26#include "client/boss_bar.h"
27#include "client/camera.h"
29#include "client/chat_window.h"
30#include "client/combat_text.h"
31#include "client/compass.h"
32#include "client/craft_window.h"
33#include "client/cursor.h"
34#include "client/death_screen.h"
35#include "client/duel_window.h"
36#include "client/foley.h"
37#include "client/gate.h"
38#include "client/gui.h"
39#include "client/guild_window.h"
40#include "client/help_window.h"
42#include "client/hotbar.h"
43#include "client/input.h"
45#include "client/jukebox.h"
46#include "client/link.h"
47#include "client/loading.h"
49#include "client/login_screen.h"
50#include "client/map.h"
51#include "client/menu.h"
52#include "client/nameplates.h"
53#include "client/names.h"
54#include "client/picking.h"
55#include "client/player_frame.h"
56#include "client/postprocess.h"
58#include "client/prediction.h"
59#include "client/quest_window.h"
60#include "client/renderer.h"
61#include "client/round_trip.h"
62#include "client/servers.h"
63#include "client/settings.h"
64#include "client/sound.h"
65#include "client/soundboard.h"
66#include "client/soundscape.h"
67#include "client/talk_window.h"
68#include "client/telegraphs.h"
69#include "client/trade_window.h"
71#include "client/translations.h"
72#include "client/window.h"
73#include "content/content.h"
74#include "protocol/settings.h"
75#include "protocol/version.h"
76#include "terrain/lands.h"
77#include "terrain/terrain.h"
78
79namespace {
80
81// The server's tick, 20 a second, which the keys go out at.
82constexpr float kInputTick = 0.05f;
83
84// In metres from where we walk to by ourselves: there.
85constexpr float kThere = 0.6f;
86
87// In seconds: a walk we asked for that stands still after this has ended, as
88// we got there, or something stopped us.
89constexpr float kSetOff = 0.5f;
90
91} // namespace
92
93int main(int argc, char* argv[]) {
94 std::cout << "nanommo client: version " << nanommo::kVersion << '\n';
95 // Offline, the world is the client's own: with --offline, and in a
96 // browser opened without a gateway to the servers.
97 const bool offline = !nanommo::CanReachServers() ||
98 (argc > 1 && std::string_view(argv[1]) == "--offline");
99 std::unique_ptr<nanommo::Servers> servers;
100 if (!offline) {
101 const std::string host = argc > 1 ? argv[1] : "localhost";
102 const std::string transport = argc > 2 ? argv[2] : "udp";
103 absl::StatusOr<std::unique_ptr<nanommo::Servers>> created =
104 nanommo::Servers::Create(host, transport == "udp");
105 if (!created.ok()) {
106 std::cerr << "nanommo client: " << created.status() << "\n";
107 return 1;
108 }
109 servers = *std::move(created);
110 }
111
112 const absl::StatusOr<nanommo::Content> content =
114 if (!content.ok()) {
115 std::cerr << "nanommo client: " << content.status() << "\n";
116 return 1;
117 }
118 const uint64_t content_hash = nanommo::ClientHash(*content);
119 std::cout << "nanommo client: content "
120 << absl::StrCat(absl::Hex(content_hash, absl::kZeroPad16)) << '\n';
121
122 absl::StatusOr<std::unique_ptr<nanommo::Window>> window_or =
123 nanommo::Window::Create("nanoMMO", 1280, 720);
124 if (!window_or.ok()) {
125 std::cerr << "nanommo client: " << window_or.status() << "\n";
126 return 1;
127 }
128 const std::unique_ptr<nanommo::Window> window = *std::move(window_or);
129 // Without a sound card, as in a container, the game plays on in silence.
130 std::unique_ptr<nanommo::AudioDevice> audio;
131 std::unique_ptr<nanommo::Track> music;
132 nanommo::Jukebox jukebox;
133 // The steps, the skills and the gates, made as the game starts.
134 std::unique_ptr<nanommo::Soundboard> soundboard;
135 nanommo::Footsteps footsteps;
136 nanommo::Casts casts;
137 nanommo::Passage passage;
138 // The weather and the time of day, as sound, all the time.
139 std::unique_ptr<nanommo::Ambience> ambience;
140 std::unique_ptr<nanommo::Stream> ambience_stream;
141 nanommo::Hearing hearing;
142 const std::string settings_path = nanommo::SettingsPath();
143 nanommo::Settings settings;
144 if (absl::StatusOr<nanommo::Settings> loaded =
145 nanommo::LoadSettings(settings_path);
146 loaded.ok()) {
147 settings = *loaded;
148 } else {
149 std::cerr << "nanommo client: " << loaded.status() << "\n";
150 }
151 nanommo::Settings saved = settings;
152 // The interface's words are in the player's language, from the settings, as
153 // soon as they pick another.
154 std::optional<std::string> language;
155 if (absl::StatusOr<std::unique_ptr<nanommo::AudioDevice>> audio_or =
157 audio_or.ok()) {
158 audio = *std::move(audio_or);
159 absl::StatusOr<std::unique_ptr<nanommo::Track>> music_or =
161 nanommo::MusicFolder() + "/background.mp3");
162 if (music_or.ok()) {
163 music = *std::move(music_or);
164 } else {
165 std::cerr << "nanommo client: " << music_or.status() << "\n";
166 }
167 // Going through a gate sounds like a teleport, if there's a recording of
168 // one.
169 soundboard = std::make_unique<nanommo::Soundboard>(
170 *audio, content->skills,
171 nanommo::LoadMono(nanommo::SoundsFolder() + "/teleport.ogg"));
172 ambience = std::make_unique<nanommo::Ambience>(
173 static_cast<uint32_t>(std::time(nullptr)));
174 // Real rain, fire and wind, where there are recordings of them.
175 nanommo::UseRecordings(*ambience);
176 ambience_stream = nanommo::Stream::Open(*audio);
177 } else {
178 std::cerr << "nanommo client: " << audio_or.status() << "\n";
179 }
180 nanommo::Gui gui;
181 nanommo::Menu menu;
182 nanommo::HelpWindow help_window;
183 nanommo::CharacterScreen character_screen(content->items);
184 nanommo::BagWindow bag_window(content->items);
185 nanommo::GuildWindow guild_window;
186 nanommo::TradeWindow trade_window(content->items);
187 nanommo::DuelWindow duel_window;
188 nanommo::ChatWindow chat_window;
189 nanommo::TalkWindow talk_window;
190 nanommo::TrainerWindow trainer_window(content->skills);
191 nanommo::HeraldWindow herald_window(content->factions);
192 nanommo::QuestWindow quest_window(*content);
193 nanommo::QuestLog quest_log(*content);
194 nanommo::CraftWindow craft_window(*content);
195 nanommo::Hotbar hotbar(content->skills);
196 hotbar.Arrange(settings.ui.hotbar);
197 nanommo::PlayerFrame player_frame(content->factions);
198 nanommo::PredictedBag predicted_bag(content->items);
199 nanommo::LoginScreen login_screen(content_hash, content->items,
200 content->figures, content->rig);
201 nanommo::Renderer renderer(*content);
203 nanommo::Animator animator(*content);
204 nanommo::Telegraphs telegraphs(content->monsters);
205 nanommo::CombatText combat_text;
206 nanommo::Loading loading;
207 nanommo::DeathScreen death_screen;
208 nanommo::LandMap land_map;
209 bool map_open = false;
210 // Whether we were trading last frame, so that the bag opens as a trade
211 // does.
212 bool trading = false;
213 std::optional<nanommo::Terrain> terrain;
214 int land = 0;
216
217 std::unique_ptr<nanommo::Link> connection;
218 // The world's next instance, while we move to it.
219 std::unique_ptr<nanommo::Link> next;
220 // The token we enter the world with, once the loading screen's up.
221 std::optional<std::string> entering;
222 std::string world_name;
223 nanommo::protocol::Input sent;
224 // The numbered keys, one each of the server's ticks.
225 uint32_t sequence = 0;
226 float input_clock = 0.0f;
227 nanommo::RoundTrip round_trip;
228 // Where we are before the server says so, from the keys we've sent, and the
229 // keys, for drawing us walking as they say.
230 nanommo::Prediction prediction;
231 // Everyone else, a moment in the past, between the worlds on either side.
232 nanommo::Interpolation interpolation;
233 int64_t corrected_at = 0;
234 Vector3 keys{0.0f, 0.0f, 0.0f};
235 bool keys_run = false;
236 // The monster the player picked, by its id, or in a duel, the player.
237 uint32_t target = 0;
238 uint32_t target_player = 0;
239 // Where we asked to walk to by ourselves, and for how long we have.
240 std::optional<Vector3> destination;
241 float walking_for = 0.0f;
242 int nearby = 0;
243
244 while (!window->ShouldClose()) {
245 if (settings.ui.language != language) {
246 if (const absl::Status used = nanommo::UseLanguage(
248 !used.ok()) {
249 std::cerr << "nanommo client: " << used << "\n";
250 }
251 language = settings.ui.language;
252 }
253 // Connecting holds up the frame, so it waits for the loading screen to be
254 // on the screen first.
255 if (entering && loading.covered()) {
256 if (offline) {
257 connection = std::make_unique<nanommo::LocalConnection>(
258 *content, nanommo::Tr("Traveller"));
259 } else if (const std::optional<nanommo::protocol::WorldListing>& world =
260 login_screen.world()) {
261 std::cout << "nanommo client: entering " << world->name() << " as "
262 << login_screen.character_name() << '\n';
263 absl::StatusOr<std::unique_ptr<nanommo::Link>> entered =
264 servers->Enter(*world, *entering);
265 if (entered.ok()) {
266 connection = *std::move(entered);
267 } else {
268 login_screen.ShowError(
269 absl::Substitute(nanommo::Tr("Couldn't reach the server: $0"),
270 entered.status().message()));
271 }
272 }
273 entering.reset();
274 sent.Clear();
275 target = 0;
276 target_player = 0;
277 nearby = 0;
278 // So that the land is built again, behind the loading screen.
279 terrain.reset();
280 }
281 if (connection) {
282 connection->Poll();
283 if (const std::optional<nanommo::protocol::Move>& move =
284 connection->move();
285 move && !next) {
286 absl::StatusOr<std::unique_ptr<nanommo::Link>> next_or =
287 servers->Move(*move);
288 if (next_or.ok()) {
289 next = *std::move(next_or);
290 std::cout << "nanommo client: moving to " << move->host() << ":"
291 << move->port() << '\n';
292 } else {
293 std::cerr << "nanommo client: " << next_or.status() << "\n";
294 // The instance we're on has stopped ticking, so there's nothing left
295 // to play here.
296 connection.reset();
297 login_screen.ShowError(
298 nanommo::Tr("Lost the connection to the server."));
299 }
300 }
301 // We go over once the next instance has sent us our world, so that the
302 // world stays on the screen.
303 if (next) {
304 next->Poll();
305 if (next->world().you() != 0) {
306 connection = std::exchange(next, nullptr);
307 sent.Clear();
308 } else if (!next->connected()) {
309 next.reset();
310 connection.reset();
311 login_screen.ShowError(
312 nanommo::Tr("Lost the connection to the server."));
313 }
314 }
315 if (connection && !next && !connection->connected()) {
316 connection.reset();
317 login_screen.ShowError(
318 nanommo::Tr("Lost the connection to the server."));
319 }
320 }
321
322 // Whether our world has come, and its land is built, to be drawn.
323 bool in_world = false;
324 bool dead = false;
326 // Whoever the pointer's on, by Who, whose name shows while it's there.
327 std::optional<uint64_t> pointed;
328 if (connection) {
329 const Vector3 direction = camera.Relative(nanommo::Movement());
330 const bool run = nanommo::Running();
331 const bool attack = nanommo::Attacking();
332 sent.set_x(direction.x);
333 sent.set_z(direction.z);
334 sent.set_run(run);
335 sent.set_attack(attack);
336 sent.set_target(target);
337 sent.set_target_player(target_player);
338 // The keys go once each of the server's ticks, numbered, so that it
339 // applies them in order, a tick each, and says which it's applied. A
340 // slow frame sends three at most, as many as the server lets wait.
341 input_clock = std::min(input_clock + GetFrameTime(), kInputTick * 3);
342 while (input_clock >= kInputTick) {
343 input_clock -= kInputTick;
344 nanommo::protocol::Input numbered = sent;
345 numbered.set_sequence(++sequence);
346 numbered.set_seen(connection->whole());
347 numbered.set_drawn(interpolation.Drawn(GetTime()));
348 connection->Send(numbered);
349 round_trip.Sent(sequence, GetTime());
350 // And they walk us now, as the server will when they reach it,
351 // unless it's steering us itself, when they don't.
352 if (terrain) {
353 const bool steered = connection->world().steered();
354 prediction.Walk(*terrain, sequence, steered ? 0.0f : direction.x,
355 steered ? 0.0f : direction.z, run, kInputTick);
356 }
357 }
358 keys = direction;
359 keys_run = run;
360 round_trip.Acked(connection->world().acked(), GetTime());
361 // The keys and a swing call off a walk we asked for, as on the server.
362 if (direction.x != 0.0f || direction.z != 0.0f || attack) {
363 destination.reset();
364 }
365
366 const nanommo::protocol::World& world = connection->world();
367 if (world.players_size() != nearby) {
368 nearby = world.players_size();
369 std::cout << "nanommo client: we're player " << world.you() << ", "
370 << nearby << " nearby" << '\n';
371 }
372 // Each land has a seed of its own, so a new seed is a new land. Until
373 // our world comes, we don't know which land we're in.
374 const bool arrived = world.you() != 0;
375 const bool new_land =
376 arrived && (!terrain || terrain->seed() != world.seed());
377 // Building a land holds up the frame, so it's built behind the loading
378 // screen, once that's on the screen.
379 if (new_land && loading.covered()) {
380 // A land this client doesn't know, from a newer server, looks like
381 // the Meadows.
382 land = world.land() < nanommo::kLands.size()
383 ? static_cast<int>(world.land())
384 : 0;
385 terrain.emplace(world.seed());
386 renderer.set_terrain(*terrain, land);
387 renderer.set_cubes(nanommo::GateCubes(*terrain, land));
388 land_map.Build(*terrain, land);
389 std::cout << "nanommo client: in the " << nanommo::kLands[land].name
390 << '\n';
391 // What we picked, and where we walked to, were the last land's.
392 target = 0;
393 target_player = 0;
394 destination.reset();
395 loading.Lift();
396 } else if (!arrived || new_land) {
397 loading.Cover();
398 } else if (loading.covering()) {
399 loading.Lift();
400 }
401 in_world = arrived && terrain && terrain->seed() == world.seed();
402 }
403
404 // Asks the world to walk us there, around what's in the way.
405 const auto walk_to = [&](float x, float z) {
406 nanommo::protocol::Input walk = sent;
407 walk.mutable_walk_to()->set_x(x);
408 walk.mutable_walk_to()->set_z(z);
409 connection->Send(walk);
410 destination = Vector3{x, terrain->Height(x, z), z};
411 walking_for = 0.0f;
412 };
413
414 if (in_world) {
415 const nanommo::protocol::World& world = connection->world();
416 // A world's parts fill in its snapshot, whichever frame each comes in.
417 interpolation.Add(world, GetTime());
418 // Each world from the server puts us where it has us, after the keys it
419 // applied, and walks us again through those it hasn't yet.
420 if (world.sent() != corrected_at) {
421 corrected_at = world.sent();
422 for (const nanommo::protocol::Player& player : world.players()) {
423 if (player.id() == world.you()) {
424 prediction.Correct(*terrain, player.x(), player.z(), world.acked(),
425 kInputTick);
426 }
427 }
428 }
429 prediction.Settle(GetFrameTime());
430 std::vector<nanommo::Figure> figures = animator.Update(
431 nanommo::Predicted(interpolation.Shown(world, GetTime()), prediction,
432 keys.x, keys.z, keys_run),
433 GetFrameTime());
434 // Ourselves where the prediction has us, as the interpolation draws the
435 // others a moment ago.
436 for (nanommo::Figure& figure : figures) {
437 if (figure.you && prediction.placed()) {
438 figure.position.x = prediction.shown_x();
439 figure.position.z = prediction.shown_z();
440 }
441 }
442 for (nanommo::Figure& figure : figures) {
443 figure.position.y =
444 terrain->Height(figure.position.x, figure.position.z);
445 }
446 const auto you = std::ranges::find_if(figures, &nanommo::Figure::you);
447 dead = you != figures.end() && you->to == nanommo::protocol::MOTION_DEAD;
448 if (you != figures.end()) {
449 camera.Update(you->position, nanommo::CameraTurn(GetFrameTime()),
451 renderer.set_camera(camera.camera());
452 }
453 const Vector3 here =
454 you != figures.end() ? you->position : Vector3{0.0f, 0.0f, 0.0f};
455 if (destination) {
456 walking_for += GetFrameTime();
457 const bool there = std::hypot(here.x - destination->x,
458 here.z - destination->z) < kThere;
459 const bool stopped = walking_for > kSetOff && you != figures.end() &&
460 you->to == nanommo::protocol::MOTION_IDLE;
461 if (there || stopped || dead) {
462 destination.reset();
463 }
464 }
465 for (const nanommo::protocol::Event& event : connection->TakeEvents()) {
466 combat_text.Add(event, world.you());
467 if (event.kind() == nanommo::protocol::EVENT_HIT) {
468 renderer.Struck(event.monster(), event.player());
469 }
470 }
471 combat_text.Update(GetFrameTime());
472 nanommo::MarkQuestGivers(figures, *content, connection->quests());
473 // The monster we picked, while it's alive and near enough to be sent.
474 if (std::ranges::none_of(figures, [target](const nanommo::Figure& f) {
475 return f.monster && f.id == target &&
476 f.to != nanommo::protocol::MOTION_DEAD;
477 })) {
478 target = 0;
479 }
480 // And the player, while we're duelling them, or they're alive in the
481 // guild at war with ours.
482 const nanommo::protocol::Duel& duel = connection->duel();
483 const uint32_t opponent = duel.state() == nanommo::protocol::DUEL_FIGHTING
484 ? duel.opponent_id()
485 : 0;
486 const std::string enemy = connection->guild().war().enemy();
487 if (target_player != opponent &&
488 std::ranges::none_of(figures, [&](const nanommo::Figure& f) {
489 return f.id == target_player && nanommo::Enemy(f, enemy) &&
490 f.to != nanommo::protocol::MOTION_DEAD;
491 })) {
492 target_player = 0;
493 }
494 renderer.set_figures(std::move(figures));
495 // The sky the server sent, as much of it as the player wants.
496 renderer.set_sky(world.sky(), {.day_night = settings.graphics.day_night,
497 .weather = settings.graphics.weather});
498 renderer.Animate(GetFrameTime());
499 // We hear from where we stand, with the camera's right to our right.
500 if (soundboard) {
501 const Camera3D& eye = camera.camera();
502 const Vector3 right = Vector3Normalize(Vector3CrossProduct(
503 Vector3Subtract(eye.target, eye.position), eye.up));
504 std::map<uint64_t, nanommo::Gait> gaits;
505 std::map<uint64_t, const nanommo::Figure*> walking;
506 for (const nanommo::Figure& figure : renderer.figures()) {
507 if (const std::optional<nanommo::Gait> gait =
508 renderer.GaitOf(figure)) {
509 gaits[nanommo::Who(figure)] = *gait;
510 walking[nanommo::Who(figure)] = &figure;
511 }
512 }
513 for (const uint64_t who : footsteps.Update(gaits)) {
514 const Vector3& at = walking.at(who)->position;
515 soundboard->Step(nanommo::GroundAt(*terrain, land, at.x, at.z),
516 nanommo::Hear(at, here, right));
517 }
518 for (const nanommo::Figure& figure : casts.Update(renderer.figures())) {
519 soundboard->Skill(figure.to_skill,
520 figure.target != 0 || figure.target_player != 0,
521 nanommo::Hear(figure.position, here, right));
522 }
523 // By the sea, if there's water a few steps from us, which the rain
524 // falls on.
525 bool by_water = false;
526 for (const auto& [dx, dz] : {std::pair{0.0f, 0.0f},
527 {8.0f, 0.0f},
528 {-8.0f, 0.0f},
529 {0.0f, 8.0f},
530 {0.0f, -8.0f}}) {
531 by_water = by_water || terrain->Height(here.x + dx, here.z + dz) <
533 }
534 nanommo::protocol::Sky sky = world.sky();
535 if (!settings.graphics.day_night) {
536 sky.set_day(0.5f);
537 }
538 hearing =
539 nanommo::HearingOf(land, sky, by_water, settings.graphics.weather);
540 for (const nanommo::Bolt& bolt : renderer.weather().TakeBolts()) {
541 if (ambience) {
542 ambience->Thunder(Vector3Distance(bolt.at, here),
543 nanommo::Hear(bolt.at, here, right).pan);
544 }
545 }
546 }
547 // A click on someone to talk to opens their window, one on a monster,
548 // or on our opponent in a duel or an enemy at war, picks it, and one on
549 // neither lets go of what we'd picked. The cursor says which a click
550 // would do.
551 if (!ImGui::GetIO().WantCaptureMouse && !dead) {
552 const Ray ray =
553 GetScreenToWorldRay(GetMousePosition(), camera.camera());
554 const nanommo::Figure* npc =
555 nanommo::PickNpc(renderer.figures(), ray, here);
556 const nanommo::Figure* monster =
557 npc == nullptr
558 ? nanommo::PickMonster(renderer.figures(), ray, opponent, enemy)
559 : nullptr;
560 if (npc != nullptr) {
561 pointing = nanommo::Pointing::kNpc;
562 } else if (monster != nullptr) {
564 }
565 if (const nanommo::Figure* anyone =
566 nanommo::PickAnyone(renderer.figures(), ray)) {
567 pointed = nanommo::Who(*anyone);
568 }
569 if (nanommo::ClickedWorld()) {
570 if (npc == nullptr) {
571 const bool player = monster != nullptr && !monster->monster;
572 target = monster != nullptr && !player ? monster->id : 0;
573 target_player = player ? monster->id : 0;
574 } else if (npc->talks) {
575 talk_window.Open(npc->id, npc->name);
576 } else if (npc->faction != 0) {
577 herald_window.Open(npc->id, npc->name, npc->faction);
578 } else if (!npc->quests.empty()) {
579 quest_window.Open(npc->id, npc->name, npc->quests);
580 } else {
581 trainer_window.Open(npc->id, npc->name, npc->teaches);
582 }
583 }
584 // A double click on the ground walks there, around what's in the way.
585 if (npc == nullptr && monster == nullptr &&
586 ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
587 if (const std::optional<Vector3> ground =
588 nanommo::PickGround(*terrain, ray);
589 ground && terrain->Walkable(ground->x, ground->z)) {
590 walk_to(ground->x, ground->z);
591 }
592 }
593 }
594 // Escape closes what's on top, then lets go of the monster picked, and
595 // then opens the menu.
596 if (IsKeyPressed(KEY_ESCAPE) && !nanommo::Typing()) {
597 if (menu.settings_open()) {
598 menu.CloseSettings();
599 } else if (menu.open()) {
600 menu.Close();
601 } else if (map_open) {
602 map_open = false;
603 } else if (*help_window.mutable_visible()) {
604 help_window.Toggle();
605 } else if (quest_log.visible()) {
606 quest_log.Toggle();
607 } else if (talk_window.open() || trainer_window.open() ||
608 quest_window.open() || herald_window.open()) {
609 talk_window.Close();
610 trainer_window.Close();
611 quest_window.Close();
612 herald_window.Close();
613 } else if (bag_window.visible()) {
614 bag_window.Toggle();
615 } else if (craft_window.visible()) {
616 craft_window.Toggle();
617 } else if (guild_window.visible()) {
618 guild_window.Toggle();
619 } else if (*character_screen.mutable_visible()) {
620 character_screen.Toggle();
621 } else if (target != 0 || target_player != 0) {
622 target = 0;
623 target_player = 0;
624 } else {
625 menu.Toggle();
626 }
627 }
628 if (IsKeyPressed(KEY_M) && !nanommo::Typing()) {
629 map_open = !map_open;
630 }
631 renderer.set_target(target, target_player);
632 renderer.set_destination(destination);
633 // A duel's flag, from its countdown on.
634 std::optional<Vector3> flag;
635 if (duel.has_flag()) {
636 const float x = duel.flag().x();
637 const float z = duel.flag().z();
638 flag = Vector3{x, terrain->Height(x, z), z};
639 }
640 renderer.set_flag(flag);
641 // The monsters' skills on their way, each where it was aimed.
642 telegraphs.Update(world, GetFrameTime());
643 renderer.set_telegraphs(telegraphs.shown());
644 if (IsKeyPressed(KEY_C) && !nanommo::Typing()) {
645 character_screen.Toggle();
646 }
647 if (IsKeyPressed(KEY_I) && !nanommo::Typing()) {
648 bag_window.Toggle();
649 }
650 if (IsKeyPressed(KEY_G) && !nanommo::Typing()) {
651 guild_window.Toggle();
652 }
653 if (IsKeyPressed(KEY_K) && !nanommo::Typing()) {
654 craft_window.Toggle();
655 }
656 if (IsKeyPressed(KEY_H) && !nanommo::Typing()) {
657 help_window.Toggle();
658 }
659 if (IsKeyPressed(KEY_T) && !nanommo::Typing()) {
660 quest_log.Toggle();
661 }
662 if (IsKeyPressed(KEY_O) && !nanommo::Typing()) {
663 if (menu.settings_open()) {
664 menu.CloseSettings();
665 } else {
666 menu.OpenSettings();
667 }
668 }
669 character_screen.Render(renderer);
670 player_frame.Render(renderer);
671 } else if (!entering) {
672 // The character picked on the login screen, drawn before the frame.
673 login_screen.Render(renderer);
674 }
675
676 // Before the frame is drawn, so that the frame we're back in is the dark
677 // one, which hides our jump to the middle.
678 death_screen.Update(GetFrameTime(), dead);
679
680 // The world goes into a frame of its own, which the screen gets from there.
681 if (in_world) {
682 renderer.set_cel_shading(settings.graphics.cel_shading);
683 renderer.set_clear(loading.clear());
684 post.Begin(settings.graphics);
685 renderer.Draw();
686 post.End();
687 }
688 BeginDrawing();
689 if (in_world) {
690 post.Draw();
691 } else {
692 renderer.Clear();
693 }
694 gui.Begin(settings.ui.scale);
695 if (in_world) {
696 nanommo::DrawNameplates(renderer.figures(), renderer.camera(),
697 telegraphs.shown(),
698 connection->guild().war().enemy(),
699 {.settings = settings.ui.nameplates,
700 .pointed = pointed,
701 .target = target,
702 .target_player = target_player});
703 nanommo::DrawCombatText(combat_text, renderer.figures(),
704 renderer.camera());
705 // Over the nameplates, and under the windows.
706 if (death_screen.Build(dead, connection->world().respawn())) {
707 nanommo::protocol::Input respawn = sent;
708 respawn.set_respawn(true);
709 connection->Send(respawn);
710 }
712 nanommo::Heading(renderer.camera()),
713 nanommo::CompassMarks(renderer.figures(), land, target, destination));
714 player_frame.Draw(renderer.figures(), connection->world());
715 nanommo::DrawTargetFrame(renderer.figures(), target, target_player);
716 if (const nanommo::Figure* boss =
717 nanommo::ShownBoss(renderer.figures(), target)) {
718 nanommo::DrawBossBar(*boss, content->monsters);
719 }
720 if (const std::optional<uint32_t> skill = hotbar.Build(
721 renderer.figures(), connection->world(), target, target_player)) {
722 nanommo::protocol::Input use = sent;
723 use.set_skill(*skill);
724 connection->Send(use);
725 destination.reset();
726 }
727 if (hotbar.TakeRearranged()) {
728 settings.ui.hotbar = hotbar.Order();
729 }
730 if (settings.ui.minimap &&
731 land_map.DrawMinimap(renderer.figures(), target, destination,
732 nanommo::Heading(renderer.camera()),
733 settings.ui.minimap_turns
736 map_open = !map_open;
737 }
738 // Without the minimap, what goes under it goes up into the corner.
739 const float under =
740 settings.ui.minimap ? land_map.minimap_bottom() : 0.0f;
742 *content, connection->quests(),
743 under + nanommo::DrawRoundTrip(round_trip.milliseconds(), under));
744 if (const std::optional<nanommo::Place> place = land_map.DrawMap(
745 renderer.figures(), target, destination, &map_open);
746 place && terrain->Walkable(place->x, place->z)) {
747 walk_to(place->x, place->z);
748 }
749 if (const std::optional<std::string> line =
750 chat_window.Build(connection->chat(), *content)) {
751 // With what we sent last, so that we keep moving as we were.
752 nanommo::protocol::Input say = sent;
753 if (const std::optional<std::string> to_guild =
754 nanommo::GuildLine(*line)) {
755 say.mutable_guild()->set_say(*to_guild);
756 } else if (const std::optional<std::string> trader =
757 nanommo::TradeName(*line)) {
758 say.mutable_trade()->set_ask(*trader);
759 } else if (const std::optional<std::string> war =
760 nanommo::WarName(*line)) {
761 say.mutable_guild()->set_war(*war);
762 } else if (std::optional<nanommo::protocol::DuelAction> duel =
763 nanommo::DuelLine(*line)) {
764 *say.mutable_duel() = *std::move(duel);
765 } else {
766 say.set_say(*line);
767 }
768 connection->Send(say);
769 }
770 if (const std::optional<nanommo::protocol::Talk> talk =
771 talk_window.Build()) {
772 nanommo::protocol::Input ask = sent;
773 *ask.mutable_talk() = *talk;
774 connection->Send(ask);
775 }
776 if (const std::optional<nanommo::protocol::Learn> learn =
777 trainer_window.Build(renderer.figures(), connection->world())) {
778 nanommo::protocol::Input ask = sent;
779 *ask.mutable_learn() = *learn;
780 connection->Send(ask);
781 }
782 if (const std::optional<uint32_t> herald =
783 herald_window.Build(renderer.figures())) {
784 nanommo::protocol::Input ask = sent;
785 ask.set_enlist(*herald);
786 connection->Send(ask);
787 }
788 if (const std::optional<nanommo::protocol::Input> quest =
789 quest_window.Build(connection->quests())) {
790 nanommo::protocol::Input ask = sent;
791 ask.MergeFrom(*quest);
792 connection->Send(ask);
793 }
794 if (const std::optional<nanommo::protocol::Input> given_up =
795 quest_log.Build(connection->quests())) {
796 nanommo::protocol::Input ask = sent;
797 ask.MergeFrom(*given_up);
798 connection->Send(ask);
799 }
800 // What the player does with their items, in either window, goes with
801 // what we sent last, like a line of chat.
802 // The bag as it'll be, with what we've just done in it already.
803 const nanommo::protocol::Inventory bag =
804 predicted_bag.Shown(connection->inventory(), GetFrameTime());
805 std::optional<nanommo::protocol::ItemAction> item =
806 character_screen.Build(renderer.figures(), connection->world(), bag);
807 // A trade that opens opens the bag too, to drag what's offered from.
808 if (!connection->trade().partner().empty() && !trading) {
809 *bag_window.mutable_visible() = true;
810 }
811 trading = !connection->trade().partner().empty();
812 if (std::optional<nanommo::protocol::ItemAction> in_bag =
813 bag_window.Build(bag, connection->trade().yours())) {
814 item = std::move(in_bag);
815 }
816 if (item) {
817 nanommo::protocol::Input ask = sent;
818 *ask.mutable_item() = *item;
819 connection->Send(ask);
820 predicted_bag.Act(bag, *item);
821 }
822 if (const std::optional<nanommo::protocol::CraftAction> craft =
823 craft_window.Build(renderer.figures(), bag,
824 connection->world().crafting())) {
825 nanommo::protocol::Input ask = sent;
826 *ask.mutable_craft() = *craft;
827 connection->Send(ask);
828 }
829 if (std::optional<nanommo::protocol::GuildInvite> invite =
830 connection->TakeInvite()) {
831 guild_window.Invited(*std::move(invite));
832 }
833 if (const std::optional<nanommo::protocol::GuildAction> guild =
834 guild_window.Build(connection->guild(),
835 connection->world().you())) {
836 nanommo::protocol::Input ask = sent;
837 *ask.mutable_guild() = *guild;
838 connection->Send(ask);
839 }
840 if (const std::optional<nanommo::protocol::TradeAction> trade =
841 trade_window.Build(connection->trade())) {
842 nanommo::protocol::Input ask = sent;
843 *ask.mutable_trade() = *trade;
844 connection->Send(ask);
845 }
846 if (const std::optional<nanommo::protocol::DuelAction> answer =
847 duel_window.Build(connection->duel())) {
848 nanommo::protocol::Input ask = sent;
849 *ask.mutable_duel() = *answer;
850 connection->Send(ask);
851 }
852 help_window.Build();
853 menu.BuildButtons(
854 character_screen.mutable_visible(), bag_window.mutable_visible(),
855 quest_log.mutable_visible(), guild_window.mutable_visible(),
856 &map_open, help_window.mutable_visible());
857 bool reset_hotbar = false;
858 switch (menu.Build(settings, &reset_hotbar)) {
860 connection.reset();
861 break;
863 window->Close();
864 break;
866 break;
867 }
868 if (reset_hotbar) {
869 hotbar = nanommo::Hotbar(content->skills);
870 }
871 } else if (!connection && !entering && !offline) {
872 if (const auto request = login_screen.Build()) {
873 absl::StatusOr<nanommo::protocol::LoginReply> reply =
874 servers->Ask(*request);
875 if (!reply.ok()) {
876 login_screen.ShowError(
877 absl::Substitute(nanommo::Tr("Couldn't reach the server: $0"),
878 reply.status().message()));
879 } else {
880 // A token for the character picked: into its world, behind the
881 // loading screen. Anything else, the screen shows.
882 if (request->enter() && reply->ok()) {
883 entering = reply->token();
884 world_name = login_screen.world()->name();
885 loading.Cover();
886 } else {
887 login_screen.Show(*reply);
888 }
889 }
890 }
891 }
892 // Offline, there's nothing to log in to, so we go straight in, and
893 // logging out starts a world afresh.
894 if (offline && !connection && !entering) {
895 entering = "offline";
896 world_name = nanommo::Tr("Offline");
897 loading.Cover();
898 }
899 // Back on the login screen, there's nothing to cover.
900 if (!connection && !entering) {
901 loading = nanommo::Loading();
902 }
903 // While our world hasn't come, we're entering it; once it has, the
904 // screen says which land it's in, in that land's sky.
905 if (connection && connection->world().you() != 0) {
906 const uint32_t shown = connection->world().land();
907 const int arriving =
908 shown < nanommo::kLands.size() ? static_cast<int>(shown) : 0;
910 loading.cover(), nanommo::kLooks[arriving].atmosphere.sky,
911 absl::Substitute(nanommo::Tr("The $0"),
912 nanommo::LandName(nanommo::kLands[arriving].name)),
913 world_name);
914 } else {
916 nanommo::kLooks[land].atmosphere.sky,
917 world_name, nanommo::Tr("Entering the world"));
918 }
919 nanommo::UpdateCursor(pointing);
920 // Once a slider lets go, so that a drag across one writes once.
921 if (settings != saved && !ImGui::IsAnyItemActive()) {
922 if (const absl::Status written =
923 nanommo::SaveSettings(settings_path, settings);
924 !written.ok()) {
925 std::cerr << "nanommo client: " << written << "\n";
926 }
927 saved = settings;
928 }
929 gui.End();
930 EndDrawing();
931 loading.Update(GetFrameTime());
932
933 if (music) {
934 switch (jukebox.Update(GetFrameTime(), in_world, music->playing())) {
936 music->Play();
937 break;
939 music->Stop();
940 break;
942 break;
943 }
944 music->SetVolume(nanommo::Gain(settings.sound.music) * jukebox.volume());
945 music->Update();
946 }
947 // Out of the world, it fades to quiet.
948 if (ambience_stream) {
949 if (!in_world) {
950 hearing = nanommo::Hearing();
951 }
952 ambience_stream->SetVolume(nanommo::Gain(settings.sound.effects));
953 ambience_stream->Feed([&](std::span<float> left, std::span<float> right) {
954 ambience->Fill(left, right, hearing);
955 });
956 }
957 if (soundboard) {
958 soundboard->set_volume(nanommo::Gain(settings.sound.effects));
959 switch (passage.Update(loading.covering(), in_world)) {
961 soundboard->Departure();
962 break;
964 soundboard->Arrival(land);
965 break;
967 break;
968 }
969 }
970 // The master volume covers each sound the game makes.
971 if (audio) {
972 SetMasterVolume(
973 settings.sound.muted ? 0.0f : nanommo::Gain(settings.sound.master));
974 }
975 }
976 return 0;
977}
std::vector< Figure > Update(const protocol::World &world, float seconds)
Definition animator.cc:150
static absl::StatusOr< std::unique_ptr< AudioDevice > > Create()
Definition audio.cc:75
std::optional< protocol::ItemAction > Build(const protocol::Inventory &bag, const protocol::TradeSide &offered={})
What's offered in a trade stays in its slot until the trade's over.
bool * mutable_visible()
Definition bag_window.h:62
bool visible() const
Definition bag_window.h:63
std::vector< Figure > Update(const std::vector< Figure > &figures)
std::optional< protocol::ItemAction > Build(const std::vector< Figure > &figures, const protocol::World &world, const protocol::Inventory &bag)
void Render(const Renderer &renderer)
std::optional< std::string > Build(const std::deque< protocol::Chat > &lines, const Content &content)
void Add(const protocol::Event &event, uint32_t you)
Adds what the event shows, to the player whose id is you.
void Update(float seconds)
Ages each by the frame's time, and drops the ones past their life.
bool visible() const
std::optional< protocol::CraftAction > Build(const std::vector< Figure > &figures, const protocol::Inventory &bag, const protocol::Crafting &making)
void Update(float seconds, bool dead)
Moves on by the frame's time, from whether the player's dead.
bool Build(bool dead, uint32_t wait_ms) const
std::optional< protocol::DuelAction > Build(const protocol::Duel &duel)
Draws what the duel needs now. Returns the player's answer, once.
Follows your player around, from behind and above.
Definition camera.h:14
const Camera3D & camera() const
Definition camera.h:28
void Update(Vector3 player, float turn, float tilt, float zoom, const Terrain &terrain)
Definition camera.cc:31
Vector3 Relative(Vector3 direction) const
Definition camera.cc:48
std::vector< uint64_t > Update(const std::map< uint64_t, Gait > &gaits)
Definition soundscape.cc:92
void End()
Definition gui.cc:36
void Begin(float player_scale=1.0f)
Definition gui.cc:24
void Invited(protocol::GuildInvite invite)
bool visible() const
std::optional< protocol::GuildAction > Build(const protocol::Guild &yours, uint32_t you)
bool * mutable_visible()
Definition help_window.h:10
void Open(uint32_t npc, std::string name, uint32_t faction)
The herald, by the NPC's id, and their faction, by its id.
std::optional< uint32_t > Build(const std::vector< Figure > &figures)
void Arrange(const std::vector< uint32_t > &order)
Definition hotbar.cc:126
std::vector< uint32_t > Order() const
The skills after the swing, by their ids, in their slots' order.
Definition hotbar.cc:118
std::optional< uint32_t > Build(const std::vector< Figure > &figures, const protocol::World &world, uint32_t target, uint32_t target_player=0)
Definition hotbar.cc:141
bool TakeRearranged()
Whether the player has swapped two skills since this was last asked.
Definition hotbar.cc:139
void Add(const protocol::World &world, double now)
int64_t Drawn(double now) const
protocol::World Shown(const protocol::World &newest, double now) const
Cue Update(float seconds, bool in_world, bool playing)
Definition jukebox.cc:7
float volume() const
From nothing to the track's full volume.
Definition jukebox.h:25
std::optional< Place > DrawMap(const std::vector< Figure > &figures, uint32_t target, std::optional< Vector3 > destination, bool *open) const
Definition map.cc:453
float minimap_bottom() const
Definition map.h:54
void Build(const Terrain &terrain, int land)
Draws the land into the texture, in place of the last one.
Definition map.cc:324
bool DrawMinimap(const std::vector< Figure > &figures, uint32_t target, std::optional< Vector3 > destination, float heading, MinimapTurn turn)
Definition map.cc:342
float clear() const
Definition loading.cc:70
void Lift()
The land is built, so the cover fades and the fog lifts.
Definition loading.cc:35
float cover() const
How much of the screen the cover hides, from 0 to 1.
Definition loading.cc:57
void Cover()
Covers the world from the next frame on.
Definition loading.cc:28
bool covering() const
Whether the cover's up, or going up.
Definition loading.h:28
bool covered() const
Definition loading.h:25
void Update(float seconds)
Moves on by the frame's time, once the frame is drawn.
Definition loading.cc:40
void Show(const protocol::LoginReply &reply)
std::string character_name() const
The name of the character picked, once it's entering.
void Render(const Renderer &renderer)
const std::optional< protocol::WorldListing > & world() const
The world picked, which a token from an enter request is for.
void ShowError(std::string error)
std::optional< protocol::LoginRequest > Build()
void Close()
Definition menu.h:20
void OpenSettings()
Definition menu.h:23
bool open() const
Definition menu.h:18
void Toggle()
Definition menu.h:19
void CloseSettings()
Definition menu.h:24
Choice Build(Settings &settings, bool *reset_hotbar)
Definition menu.cc:98
void BuildButtons(bool *character, bool *bag, bool *quests, bool *guild, bool *map, bool *help)
Definition menu.cc:263
bool settings_open() const
Definition menu.h:22
Cue Update(bool covering, bool in_world)
void Draw(const std::vector< Figure > &figures, const protocol::World &world) const
void Render(const Renderer &renderer)
void Draw()
Draws the frame to the screen, with bloom if it's on.
void Begin(const GraphicsSettings &graphics)
protocol::Inventory Shown(const protocol::Inventory &server, float seconds)
void Act(const protocol::Inventory &server, const protocol::ItemAction &action)
What the player asked for, done to the bag shown, if the rules allow it.
float x() const
Definition prediction.h:35
float shown_z() const
Definition prediction.h:38
float shown_x() const
Definition prediction.h:37
void Walk(const Terrain &terrain, uint32_t sequence, float direction_x, float direction_z, bool run, float seconds)
Definition prediction.cc:25
bool placed() const
Definition prediction.h:39
void Settle(float seconds)
Fades what the last corrections moved, over the frame's time.
Definition prediction.cc:91
void Correct(const Terrain &terrain, float x, float z, uint32_t acked, float seconds)
Definition prediction.cc:37
bool visible() const
std::optional< protocol::Input > Build(const protocol::Quests &yours)
bool * mutable_visible()
std::optional< protocol::Input > Build(const protocol::Quests &yours)
void Open(uint32_t npc, std::string name, std::vector< uint32_t > quests)
void Struck(uint32_t monster, uint32_t player)
The player hit the monster, both by their ids.
Definition renderer.h:113
std::optional< Gait > GaitOf(const Figure &figure) const
Definition renderer.cc:609
void set_figures(std::vector< Figure > figures)
Definition renderer.h:97
void set_camera(const Camera3D &camera)
Definition renderer.h:77
void set_clear(float clear)
Definition renderer.h:142
Weather & weather()
Definition renderer.h:74
void set_cel_shading(bool on)
Cel shading's bands and outlines, on or off. It starts off.
Definition renderer.cc:421
void set_terrain(const Terrain &terrain, int land)
Definition renderer.cc:408
void Animate(float seconds)
Definition renderer.cc:435
void set_sky(const protocol::Sky &sky, const Showing &showing)
Definition renderer.h:58
const std::vector< Figure > & figures() const
Definition renderer.h:96
void Draw() const
Definition renderer.cc:477
void set_flag(std::optional< Vector3 > flag)
Definition renderer.h:132
void set_cubes(std::vector< Cube > cubes)
Definition renderer.h:86
void set_telegraphs(std::map< uint32_t, Telegraph > telegraphs)
Definition renderer.h:136
void set_destination(std::optional< Vector3 > destination)
Definition renderer.h:126
const Camera3D & camera() const
Definition renderer.h:76
void set_target(uint32_t target, uint32_t player=0)
Definition renderer.h:119
void Clear() const
Definition renderer.cc:639
void Sent(uint32_t sequence, double now)
We sent the input of that sequence, at the time, in seconds.
Definition round_trip.cc:24
float milliseconds() const
In milliseconds, smoothed over the last few, or 0 before any.
Definition round_trip.h:20
void Acked(uint32_t acked, double now)
The world says the server applied the inputs up to acked.
Definition round_trip.cc:26
static absl::StatusOr< std::unique_ptr< Servers > > Create(std::string host, bool udp)
Definition servers.cc:75
static std::unique_ptr< Stream > Open(const AudioDevice &device)
Definition audio.cc:140
bool open() const
Definition talk_window.h:20
void Open(uint32_t npc, std::string name)
std::optional< protocol::Talk > Build()
void Update(const protocol::World &world, float seconds)
Definition telegraphs.cc:15
const std::map< uint32_t, Telegraph > & shown() const
By the monster's id.
Definition telegraphs.h:42
static constexpr float kSeaLevel
Definition terrain.h:50
static absl::StatusOr< std::unique_ptr< Track > > Load(const AudioDevice &device, const std::string &path)
Loading needs the device, so it takes one, even though it doesn't use it.
Definition audio.cc:85
std::optional< protocol::TradeAction > Build(const protocol::Trade &trade)
std::optional< protocol::Learn > Build(const std::vector< Figure > &figures, const protocol::World &world)
void Open(uint32_t npc, std::string name, std::vector< uint32_t > teaches)
std::vector< Bolt > TakeBolts()
The bolts that struck since the last time, once each.
Definition weather.cc:402
static absl::StatusOr< std::unique_ptr< Window > > Create(const std::string &title, int width, int height, Visibility visibility=Visibility::kShown)
Definition window.cc:13
int main()
Definition login_main.cc:28
Vector3 Movement()
x is to the right and z is towards the camera, each -1, 0 or 1.
Definition input.cc:24
bool Running()
Definition input.cc:48
protocol::World Predicted(const protocol::World &world, const Prediction &prediction, float direction_x, float direction_z, bool run)
Definition prediction.cc:60
void DrawNameplates(const std::vector< Figure > &figures, const Camera3D &camera, const std::map< uint32_t, Telegraph > &telegraphs, std::string_view enemy, const Noticed &noticed)
void DrawBossBar(const Figure &boss, const MonsterTable &monsters)
Definition boss_bar.cc:54
float CameraZoom()
Definition input.cc:97
bool CanReachServers()
Whether this build can reach the servers at all: a browser's can't.
Definition servers.cc:73
void DrawTargetFrame(const std::vector< Figure > &figures, uint32_t target, uint32_t target_player)
const Figure * ShownBoss(const std::vector< Figure > &figures, uint32_t target)
Definition boss_bar.cc:29
constexpr std::array< Look, 3 > kLooks
In the order of the lands.
Definition atmosphere.h:164
void MarkQuestGivers(std::vector< Figure > &figures, const Content &content, const protocol::Quests &yours)
float Heading(const Camera3D &camera)
Definition compass.cc:111
Ground GroundAt(const Terrain &terrain, int land, float x, float z)
What's underfoot there: the water we wade in, or the land's surface.
Definition foley.cc:97
std::optional< std::string > WarName(std::string_view typed)
absl::StatusOr< Settings > LoadSettings(const std::string &path)
Definition settings.cc:44
void DrawCompass(float heading, const std::vector< CompassMark > &marks)
Definition compass.cc:166
const char * Tr(const char *text)
void UpdateCursor(Pointing pointing)
Definition cursor.cc:35
uint64_t ClientHash(const Content &content)
Definition content.cc:232
float DrawRoundTrip(float milliseconds, float top)
Definition round_trip.cc:39
std::vector< Cube > GateCubes(const Terrain &terrain, int land)
Definition gate.cc:35
std::string LandName(std::string_view land)
Definition names.cc:92
void UseRecordings(Ambience &ambience)
Definition audio.cc:37
uint64_t Who(const Figure &figure)
Definition animator.cc:124
constexpr std::array< Land, 3 > kLands
Definition lands.h:31
std::vector< CompassMark > CompassMarks(const std::vector< Figure > &figures, int land, uint32_t target, std::optional< Vector3 > destination)
Definition compass.cc:125
bool Enemy(const Figure &figure, std::string_view enemy)
Definition picking.cc:68
bool Attacking()
Definition input.cc:52
const Figure * PickMonster(const std::vector< Figure > &figures, const Ray &ray, uint32_t opponent, std::string_view enemy)
Definition picking.cc:73
float CameraTurn(float seconds)
Definition input.cc:73
std::optional< Vector3 > PickGround(const Terrain &terrain, const Ray &ray)
Definition picking.cc:93
Pointing
What the mouse is over in the world.
Definition cursor.h:7
bool Typing()
Definition input.cc:22
absl::Status SaveSettings(const std::string &path, const Settings &player)
Definition settings.cc:118
float Gain(float slider)
Definition sound.cc:13
std::string ContentFolder()
const Figure * PickAnyone(const std::vector< Figure > &figures, const Ray &ray)
Definition picking.cc:82
void DrawLoadingScreen(float cover, const std::array< float, 3 > &sky, const std::string &title, const std::string &line)
Definition loading.cc:83
std::optional< std::string > TradeName(std::string_view typed)
float CameraTilt()
Definition input.cc:89
std::optional< protocol::DuelAction > DuelLine(std::string_view typed)
Heard Hear(Vector3 source, Vector3 ears, Vector3 right)
Definition soundscape.cc:21
std::string SettingsPath()
Definition settings.cc:34
bool ClickedWorld()
Definition input.cc:68
Hearing HearingOf(int land, const protocol::Sky &sky, bool by_water, bool weather)
Definition ambience.cc:340
std::string SoundsFolder()
Where the recorded sounds are, beside the music.
Definition audio.cc:49
std::optional< Samples > LoadMono(const std::string &path)
The same, with its two channels as one.
Definition audio.cc:25
std::string LanguageFolder()
Where the PO files are, next to the client.
std::string MusicFolder()
Definition audio.cc:21
std::optional< std::string > GuildLine(std::string_view typed)
void DrawQuestTracker(const Content &content, const protocol::Quests &yours, float top)
const Figure * PickNpc(const std::vector< Figure > &figures, const Ray &ray, Vector3 you)
Definition picking.cc:57
absl::StatusOr< Content > ReadContent(const std::string &folder)
Reads each file in the folder, or says which file is wrong, and where.
Definition content.cc:64
absl::Status UseLanguage(std::string_view code, const std::string &folder)
void DrawCombatText(const CombatText &text, const std::vector< Figure > &figures, const Camera3D &camera)
Draws each over the figure it's about, rising and fading as it ages.
Where a bolt of lightning struck, for its thunder to come from.
Definition weather.h:17
uint32_t id
Definition animator.h:21
std::string name
Definition animator.h:22
std::vector< uint32_t > quests
The quests an NPC gives, by their ids in the quests file.
Definition animator.h:44
std::vector< uint32_t > teaches
The skills an NPC teaches, by their ids, when it's a trainer.
Definition animator.h:42
bool talks
Whether the player can talk to it, by clicking it.
Definition animator.h:40
protocol::Motion to
Definition animator.h:77
uint32_t faction
Definition animator.h:27
std::vector< uint32_t > hotbar
Definition settings.h:44
What the player sets, which the client keeps between runs.
Definition settings.h:54
InterfaceSettings ui
Definition settings.h:57
SoundSettings sound
Definition settings.h:55
GraphicsSettings graphics
Definition settings.h:56
float effects
The sound effects, apart from the music.
Definition sound.h:12
float master
Where the sliders are, from nothing to full.
Definition sound.h:9