Skip to content

Commit

Permalink
fix syncing by normalizing whitespace in room description
Browse files Browse the repository at this point in the history
  • Loading branch information
nschimme committed Mar 10, 2024
1 parent 6433e4a commit cfd7701
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/expandoracommon/parseevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@

#include "parseevent.h"

#include <algorithm>
#include <cassert>
#include <cstdint>
#include <memory>
#include <regex>

#include "../global/TextUtils.h"
#include "../global/utils.h"
#include "../mapdata/ExitDirection.h"
#include "../parser/CommandId.h"
#include "../parser/ConnectedRoomFlags.h"
Expand Down Expand Up @@ -110,9 +109,11 @@ SharedParseEvent ParseEvent::createEvent(const CommandEnum c,
auto result = std::make_shared<ParseEvent>(c);
ParseEvent *const event = result.get();

static const std::regex normalizeWhitespacePattern(R"(\s+)", std::regex::optimize);

// the moved strings are used by const ref here before they're moved.
event->setProperty(moved_roomName);
event->setProperty(moved_roomDesc);
event->setProperty(RoomDesc{std::regex_replace(moved_roomDesc.getStdString(), normalizeWhitespacePattern, " ")});
event->setProperty(terrain);

// After this block, the moved values are gone.
Expand Down

0 comments on commit cfd7701

Please sign in to comment.