Crossfire Server, Trunk  1.75.0
Utils.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2020 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 "Utils.h"
14 #include <vector>
15 
16 bool Utils::endsWith(const char * const str, const char * const with) {
17  return
18  strlen(str) >= strlen(with) &&
19  strcmp(&str[strlen(str) - strlen(with)], with) == 0;
20 }
21 
23  std::vector<std::string> items;
24  while (list) {
25  items.push_back(list->name);
26  list = list->next;
27  }
28 
29  bool first = true;
30  for (auto a = items.rbegin(); a != items.rend(); a++) {
31  stringbuffer_append_printf(buf, "%c%s", first ? ' ' : ',', (*a).c_str());
32  first = false;
33  }
34 }
35 
36 void Utils::writeStringArray(char **items, size_t count, StringBuffer *buf) {
37  bool first = true;
38  for (size_t item = 0; item < count; item++) {
39  stringbuffer_append_printf(buf, "%c%s", first ? ' ' : ',', items[item]);
40  first = false;
41  }
42 }
stringbuffer_append_printf
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Append a formatted string to a string buffer instance.
Definition: stringbuffer.cpp:138
buf
StringBuffer * buf
Definition: readable.cpp:1565
linked_char
Definition: global.h:98
Utils.h
StringBuffer
A buffer that will be expanded as content is added to it.
Definition: stringbuffer.cpp:25
a
Magical Runes Runes are magical inscriptions on the dungeon which cast a spell or detonate when something steps on them Flying objects don t detonate runes Beware ! Runes are invisible most of the time They are only visible occasionally ! There are several runes which are there are some special runes which may only be called with the invoke and people may apply it to read it Maybe useful for mazes ! This rune will not nor is it ordinarily invisible Partial Visibility of they ll be visible only part of the time They have a(your level/2) chance of being visible in any given round
list
How to Install a Crossfire Server on you must install a python script engine on your computer Python is the default script engine of Crossfire You can find the python engine you have only to install them The VisualC Crossfire settings are for but you habe then to change the pathes in the VC settings Go in Settings C and Settings Link and change the optional include and libs path to the new python installation path o except the maps ! You must download a map package and install them the share folder Its must look like doubleclick on crossfire32 dsw There are projects in your libcross lib and plugin_python You need to compile all Easiest way is to select the plugin_python ReleaseLog as active this will compile all others too Then in Visual C press< F7 > to compile If you don t have an appropriate compiler you can try to get the the VC copies the crossfire32 exe in the crossfire folder and the plugin_python dll in the crossfire share plugins folder we will remove it when we get time for it o Last showing lots of weird write to the Crossfire mailing list
Definition: INSTALL_WIN32.txt:50
Utils::writeStringArray
static void writeStringArray(char **items, size_t count, StringBuffer *buf)
Write a list of strings as ' a,b,c' (leading space).
Definition: Utils.cpp:36
Utils::endsWith
static bool endsWith(const char *const str, const char *const with)
Checks if a string ends with another one.
Definition: Utils.cpp:16
Utils::writeLinkedChar
static void writeLinkedChar(const linked_char *list, StringBuffer *buf)
Write a list of strings as ' a,b,c' (leading space).
Definition: Utils.cpp:22