Crossfire Server, Trunk
AttackMessagePanel.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 <QTableWidget>
14 #include "AttackMessagePanel.h"
15 #include "AttackMessagesWrapper.h"
16 #include "global.h"
17 #include "attack.h"
18 #include "sproto.h"
19 
20 AttackMessagePanel::AttackMessagePanel(QWidget* parent) : AssetSWrapperPanel(parent), myAttackType(0) {
21  myMessages = addWidget(nullptr, new QTableWidget(0, 4, this), false, nullptr, nullptr);
22  myMessages->setHorizontalHeaderLabels({tr("Max damage"), tr("First part"), tr("Second part"), tr("For victim")});
23  myMessages->setEditTriggers(QAbstractItemView::NoEditTriggers);
24  myMessages->setSelectionBehavior(QAbstractItemView::SelectRows);
25  myMessages->verticalHeader()->setVisible(false);
26  connect(myMessages, &QTableWidget::currentCellChanged, this, &AttackMessagePanel::currentCellChanged);
27  myForHitter = addLabel(nullptr, nullptr);
28  myForHitter->setTextInteractionFlags(Qt::TextSelectableByMouse);
29  myForVictim = addLabel(nullptr, nullptr);
30  myForVictim->setTextInteractionFlags(Qt::TextSelectableByMouse);
31 }
32 
33 static QTableWidgetItem *createItem(const QString &text) {
34  auto item = new QTableWidgetItem(text);
35  item->setData(Qt::ToolTipRole, text);
36  return item;
37 }
38 
40  myMessages->setRowCount(0);
42 
43  for (int message = 0; message < MAXATTACKMESS && attack_mess[myAttackType][message].level != -1; message++) {
44  myMessages->setRowCount(message + 1);
45  myMessages->setItem(message, 0, createItem(QString::number(attack_mess[myAttackType][message].level)));
49  }
50 }
51 
52 void AttackMessagePanel::currentCellChanged(int currentRow, int, int, int) {
53  myForHitter->clear();
54  myForVictim->clear();
55  if (currentRow < 0 || currentRow >= NROFATTACKMESS || attack_mess[myAttackType][currentRow].level == -1) {
56  return;
57  }
58 
59  char buf1[MAX_BUF], buf2[MAX_BUF];
60  get_attack_message_for_attack_type(attack_mess[myAttackType][currentRow].level - 1, myAttackType, "victim", buf1, buf2);
61  myForHitter->setText(QString("You %1").arg(buf1));
62  myForVictim->setText(QString("Hitter%1 you").arg(buf2));
63 }
NROFATTACKMESS
#define NROFATTACKMESS
Definition: attack.h:18
global.h
AssetWrapperPanel::addLabel
QLabel * addLabel(const QString &label, const char *property, bool wrapText=false)
Definition: AssetWrapperPanel.cpp:68
AttackMessagePanel::myMessages
QTableWidget * myMessages
Definition: AttackMessagePanel.h:38
AttackMessagePanel::myForVictim
QLabel * myForVictim
Definition: AttackMessagePanel.h:40
MAXATTACKMESS
#define MAXATTACKMESS
Definition: attack.h:19
AttackMessagePanel::updateItem
virtual void updateItem() override
Definition: AttackMessagePanel.cpp:39
attack.h
AttackMessagePanel::currentCellChanged
void currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn)
Definition: AttackMessagePanel.cpp:52
AssetSWrapperPanel< SingleAttackWrapper >::myItem
SingleAttackWrapper * myItem
Definition: AssetWrapperPanel.h:126
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
AttackMessagePanel::AttackMessagePanel
AttackMessagePanel(QWidget *parent)
Definition: AttackMessagePanel.cpp:20
sproto.h
AssetSWrapperPanel
Definition: AssetWrapperPanel.h:113
SingleAttackWrapper::attackType
uint8_t attackType() const
Definition: AttackMessagesWrapper.h:25
get_attack_message_for_attack_type
void get_attack_message_for_attack_type(int dam, uint8_t atm_type, const char *victim_name, char *buf1, char *buf2)
Definition: attack.cpp:538
MAX_BUF
#define MAX_BUF
Definition: define.h:35
attack_mess
attackmess_t attack_mess[NROFATTACKMESS][MAXATTACKMESS]
Definition: init.cpp:78
AttackMessagePanel::myForHitter
QLabel * myForHitter
Definition: AttackMessagePanel.h:39
item
Definition: item.py:1
AttackMessagesWrapper.h
attackmess_t::level
int level
Definition: attack.h:119
AttackMessagePanel::myAttackType
uint8_t myAttackType
Definition: AttackMessagePanel.h:37
say.item
dictionary item
Definition: say.py:149
connect
Definition: connect.py:1
AttackMessagePanel.h
AssetWrapperPanel::addWidget
T * addWidget(const QString &label, T *widget, bool sideBySide, const char *property, const char *widgetProperty)
Definition: AssetWrapperPanel.h:64
text
Crossfire Protocol most of the time after the actual code was already omit certain important and possibly make life miserable any new developer or curious player should be able to find most of the relevant information here If inconsistencies are found or this documentation proves to be consider the latest server side protocol code in the public source code repository as the authoritative reference Introduction If you were ever curious enough to telnet or netcat to a Crossfire chances are you were sorely disappointed While the protocol may seem to use plain text at it actually uses a mix of ASCII and binary data This handbook attempts to document various aspects of the Crossfire protocol As consult the README file to find out how to get in touch with helpful people via mailing and more History the communications plan was set to be a text based system It was up to the server and client to parse these messages and determine what to do These messages were assumed to be line per message At a reasonably early stage of Eric Anderson wrote a then the data itself you could send many data and after the other end could decode these commands This works fairly but I think the creation of numerous sub packets has some performance hit the eutl was not especially well so writing a client for a different platform became more Eric left to work on other products shortly after writing his which didn t really leave anyone with a full understanding of the socket code I have decided to remove the eutl dependency At least one advantage is that having this network related code directly in the client and server makes error handling a bit easier cleaner Packet Format the outside packet method the byte size for the size information is not included here Eutl originally used bytes for the size to bytes seems it makes a least some sense The actual data is something of the nature of the commands listed below It is a text followed by possible other data The remaining data can be binary it is up to the client and server to decode what it sent The commands as described below is just the data portion of the packet If writing a new remember that you must take into account the size of the packet There is no termination of other than knowing how long it should be For most everything that is sent is text This is more or less how things worked under except it packed the ints into bytes in a known order In some we handle ints as in they are sent as binary information How any command handles it is detailed below in the command description The S and C represent the direction of the we use MSB as well as any ints or shorts that get sent inside the packets All packets are defined to have at least one word of text
Definition: protocol.txt:84
createItem
static QTableWidgetItem * createItem(const QString &text)
Definition: AttackMessagePanel.cpp:33
level
Definition: level.py:1