Crossfire Server, Trunk
GeneralMessageWrapper.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2022 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
13 #include "GeneralMessageWrapper.h"
14 #include "ResourcesManager.h"
15 
17  auto face = dynamic_cast<const FaceWrapper *> (asset);
18  if (face) {
19  return myWrappedItem->face == face->wrappedItem() ? Uses : DoesntUse;
20  }
21  auto quest = dynamic_cast<const QuestWrapper *>(asset);
22  if (quest && myWrappedItem->quest_code) {
23  std::string name(myWrappedItem->quest_code);
24  size_t len = strlen(quest->wrappedItem()->quest_code);
25  return (name.length() > len && name[len] == ' ' && name.substr(0, len) == quest->wrappedItem()->quest_code) ? Uses : DoesntUse;
26  }
27  return DoesntUse;
28 }
29 
32  AssetWrapper::wasModified(asset, type, extra);
33 }
34 
35 void GeneralMessageWrapper::setTitle(const QString &title) {
36  if (myWrappedItem->title != title) {
37  FREE_AND_COPY_IF(myWrappedItem->title, title.toLocal8Bit().data());
39  }
40 }
41 
42 void GeneralMessageWrapper::setQuest(const QString &quest) {
43  if (myWrappedItem->quest_code != quest) {
44  FREE_AND_COPY_IF(myWrappedItem->quest_code, quest.toLocal8Bit().data());
46  }
47 }
48 
50  if (chance != myWrappedItem->chance) {
53  }
54 }
55 
57  if (myWrappedItem->face != face) {
60  }
61 }
62 
64  auto msg(message);
65  if (!msg.isEmpty() && msg[msg.size() - 1] != '\n') {
66  msg += "\n";
67  }
68  if (myWrappedItem->message != msg) {
69  FREE_AND_COPY_IF(myWrappedItem->message, msg.toLocal8Bit().data());
71  }
72 }
GeneralMessageWrapper::setQuest
void setQuest(const QString &quest)
Definition: GeneralMessageWrapper.cpp:42
GeneralMessage::title
sstring title
Definition: book.h:48
GeneralMessageWrapper::wasModified
virtual void wasModified(AssetWrapper *asset, ChangeType type, int extra) override
Definition: GeneralMessageWrapper.cpp:30
GeneralMessageWrapper.h
AssetWrapper::markModified
void markModified(ChangeType change, int extra=0)
Definition: AssetWrapper.h:55
ResourcesManager::generalMessageModified
void generalMessageModified(GeneralMessage *message)
Definition: ResourcesManager.cpp:257
QuestWrapper
Definition: QuestWrapper.h:66
FREE_AND_COPY_IF
#define FREE_AND_COPY_IF(sv, nv)
Definition: global.h:206
AssetTWrapper< GeneralMessage >::myWrappedItem
GeneralMessage * myWrappedItem
Definition: AssetWrapper.h:104
GeneralMessageWrapper::message
QString message
Definition: GeneralMessageWrapper.h:34
GeneralMessage::message
sstring message
Definition: book.h:49
AssetWrapper
Definition: AssetWrapper.h:25
name
Plugin animator file specs[Config] name
Definition: animfiles.txt:4
quest
Definition: quest.py:1
FaceWrapper
Definition: FaceWrapper.h:24
GeneralMessage::quest_code
sstring quest_code
Definition: book.h:50
AssetWrapper::AssetUpdated
@ AssetUpdated
Definition: AssetWrapper.h:33
AssetWrapper::wasModified
virtual void wasModified(AssetWrapper *asset, ChangeType type, int extra)
Definition: AssetWrapper.h:78
GeneralMessageWrapper::setChance
void setChance(int chance)
Definition: GeneralMessageWrapper.cpp:49
navar-midane_pickup.msg
list msg
Definition: navar-midane_pickup.py:13
message
TIPS on SURVIVING Crossfire is populated with a wealth of different monsters These monsters can have varying immunities and attack types In some of them can be quite a bit smarter than others It will be important for new players to learn the abilities of different monsters and learn just how much it will take to kill them This section discusses how monsters can interact with players Most monsters in the game are out to mindlessly kill and destroy the players These monsters will help boost a player s after he kills them When fighting a large amount of monsters in a single attempt to find a narrower hallway so that you are not being attacked from all sides Charging into a room full of Beholders for instance would not be open the door and fight them one at a time For there are several maps designed for them Find these areas and clear them out All throughout these a player can find signs and books which they can read by stepping onto them and hitting A to apply the book sign These messages will help the player to learn the system One more always keep an eye on your food If your food drops to your character will soon so BE CAREFUL ! NPCs Non Player Character are special monsters which have intelligence Players may be able to interact with these monsters to help solve puzzles and find items of interest To speak with a monster you suspect to be a simply move to an adjacent square to them and push the double ie Enter your message
Definition: survival-guide.txt:34
GeneralMessageWrapper::chance
int chance
Definition: GeneralMessageWrapper.h:32
title
Definition: readable.cpp:108
GeneralMessageWrapper::myResources
ResourcesManager * myResources
Definition: GeneralMessageWrapper.h:60
AssetWrapper::PossibleUse
PossibleUse
Definition: AssetWrapper.h:32
AssetWrapper::Uses
@ Uses
Definition: AssetWrapper.h:32
ResourcesManager.h
GeneralMessageWrapper::setTitle
void setTitle(const QString &title)
Definition: GeneralMessageWrapper.cpp:35
GeneralMessageWrapper::uses
virtual PossibleUse uses(const AssetWrapper *asset, std::string &) const override
Definition: GeneralMessageWrapper.cpp:16
GeneralMessageWrapper::face
const Face face
Definition: GeneralMessageWrapper.h:33
GeneralMessage::face
const Face * face
Definition: book.h:51
GeneralMessageWrapper::setMessage
void setMessage(const QString &message)
Definition: GeneralMessageWrapper.cpp:63
AssetWrapper::ChangeType
ChangeType
Definition: AssetWrapper.h:33
Face
Definition: face.h:14
AssetWrapper::DoesntUse
@ DoesntUse
Definition: AssetWrapper.h:32
GeneralMessage::chance
int chance
Definition: book.h:45
GeneralMessageWrapper::setFace
void setFace(const Face *face)
Definition: GeneralMessageWrapper.cpp:56
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25