Freeciv21
Develop your civilization from humble roots to a global empire
edithand.cpp File Reference
#include <QSet>
#include <climits>
#include "bitvector.h"
#include "fcintl.h"
#include "log.h"
#include "shared.h"
#include "support.h"
#include "events.h"
#include "game.h"
#include "government.h"
#include "map.h"
#include "movement.h"
#include "nation.h"
#include "research.h"
#include "terrain.h"
#include "unitlist.h"
#include "aiiface.h"
#include "citytools.h"
#include "cityturn.h"
#include "connecthand.h"
#include "gamehand.h"
#include "hand_gen.h"
#include "maphand.h"
#include "notify.h"
#include "plrhand.h"
#include "sanitycheck.h"
#include "techtools.h"
#include "unittools.h"
#include "mapgen_utils.h"
#include "savemain.h"
#include "edithand.h"
+ Include dependency graph for edithand.cpp:

Go to the source code of this file.

Functions

void edithand_init ()
 Initialize data structures required for edit mode. More...
 
void edithand_free ()
 Free all memory used by data structures required for edit mode. More...
 
void edithand_send_initial_packets (struct conn_list *dest)
 Send the needed packets for connections entering in the editing mode. More...
 
static void check_edited_tile_terrains ()
 Do the potentially slow checks required after one or several tiles' terrain has change. More...
 
static void check_leaving_edit_mode ()
 Do any necessary checks after leaving edit mode to ensure that the game is in a consistent state. More...
 
void handle_edit_mode (struct connection *pc, bool is_edit_mode)
 Handles a request by the client to enter edit mode. More...
 
static bool edit_tile_terrain_handling (struct tile *ptile, struct terrain *pterrain, bool send_info)
 Base function to edit the terrain property of a tile. More...
 
static bool edit_tile_extra_handling (struct tile *ptile, struct extra_type *pextra, bool remove_mode, bool send_info)
 Base function to edit the extras property of a tile. More...
 
void handle_edit_tile_terrain (struct connection *pc, int tile, Terrain_type_id terrain, int size)
 Handles a client request to change the terrain of the tile at the given x, y coordinates. More...
 
void handle_edit_tile_extra (struct connection *pc, int tile, int id, bool removal, int eowner, int size)
 Handle a request to change one or more tiles' extras. More...
 
void handle_edit_tile (struct connection *pc, const struct packet_edit_tile *packet)
 Handles tile information from the client, to make edits to tiles. More...
 
void handle_edit_unit_create (struct connection *pc, int owner, int tile, Unit_type_id utid, int count, int tag)
 Handle a request to create 'count' units of type 'utid' at the tile given by the x, y coordinates and owned by player with number 'owner'. More...
 
void handle_edit_unit_remove (struct connection *pc, int owner, int tile, Unit_type_id utid, int count)
 Remove 'count' units of type 'utid' owned by player number 'owner' at tile (x, y). More...
 
void handle_edit_unit_remove_by_id (struct connection *pc, Unit_type_id id)
 Handle a request to remove a unit given by its id. More...
 
void handle_edit_unit (struct connection *pc, const struct packet_edit_unit *packet)
 Handles unit information from the client, to make edits to units. More...
 
void handle_edit_city_create (struct connection *pc, int owner, int tile, int size, int tag)
 Allows the editing client to create a city at the given position and of size 'size'. More...
 
void handle_edit_city (struct connection *pc, const struct packet_edit_city *packet)
 Handle a request to change the internal state of a city. More...
 
void handle_edit_player_create (struct connection *pc, int tag)
 Handle a request to create a new player. More...
 
void handle_edit_player_remove (struct connection *pc, int id)
 Handle a request to remove a player. More...
 
void handle_edit_player (struct connection *pc, const struct packet_edit_player *packet)
 Handle editing of any or all player properties. More...
 
void handle_edit_player_vision (struct connection *pc, int plr_no, int tile, bool known, int size)
 Handles vision editing requests from client. More...
 
void handle_edit_recalculate_borders (struct connection *pc)
 Client editor requests us to recalculate borders. More...
 
void handle_edit_city_remove (struct connection *pc, int id)
 Remove any city at the given location. More...
 
void handle_edit_check_tiles (struct connection *pc)
 Run any pending tile checks. More...
 
void handle_edit_toggle_fogofwar (struct connection *pc, int plr_no)
 Temporarily remove fog-of-war for the player with player number 'plr_no'. More...
 
void handle_edit_startpos (struct connection *pconn, const struct packet_edit_startpos *packet)
 Create or remove a start position at a tile. More...
 
void handle_edit_startpos_full (struct connection *pconn, const struct packet_edit_startpos_full *packet)
 Setup which nations can start at a start position. More...
 
void handle_edit_game (struct connection *pc, const struct packet_edit_game *packet)
 Handle edit requests to the main game data structure. More...
 
void handle_edit_scenario_desc (struct connection *pc, const char *scenario_desc)
 Handle edit requests to scenario description. More...
 
void handle_save_scenario (struct connection *pc, const char *name)
 Make scenario file out of current game. More...
 

Variables

static bool need_continents_reassigned = false
 
static bool * unfogged_players
 

Function Documentation

◆ check_edited_tile_terrains()

static void check_edited_tile_terrains ( )
static

Do the potentially slow checks required after one or several tiles' terrain has change.

Definition at line 129 of file edithand.cpp.

Referenced by check_leaving_edit_mode(), and handle_edit_check_tiles().

◆ check_leaving_edit_mode()

static void check_leaving_edit_mode ( )
static

Do any necessary checks after leaving edit mode to ensure that the game is in a consistent state.

Definition at line 149 of file edithand.cpp.

Referenced by handle_edit_mode().

◆ edit_tile_extra_handling()

static bool edit_tile_extra_handling ( struct tile ptile,
struct extra_type pextra,
bool  remove_mode,
bool  send_info 
)
static

Base function to edit the extras property of a tile.

Returns TRUE if the extra state has changed.

Definition at line 238 of file edithand.cpp.

Referenced by handle_edit_tile(), and handle_edit_tile_extra().

◆ edit_tile_terrain_handling()

static bool edit_tile_terrain_handling ( struct tile ptile,
struct terrain pterrain,
bool  send_info 
)
static

Base function to edit the terrain property of a tile.

Returns TRUE if the terrain has changed.

Definition at line 208 of file edithand.cpp.

Referenced by handle_edit_tile_terrain().

◆ edithand_free()

void edithand_free ( )

Free all memory used by data structures required for edit mode.

Definition at line 85 of file edithand.cpp.

Referenced by server_quit().

◆ edithand_init()

void edithand_init ( )

Initialize data structures required for edit mode.

Definition at line 72 of file edithand.cpp.

◆ edithand_send_initial_packets()

void edithand_send_initial_packets ( struct conn_list *  dest)

Send the needed packets for connections entering in the editing mode.

Definition at line 94 of file edithand.cpp.

Referenced by connection_attach_real(), and handle_edit_mode().

◆ handle_edit_check_tiles()

void handle_edit_check_tiles ( struct connection pc)

Run any pending tile checks.

Definition at line 1275 of file edithand.cpp.

◆ handle_edit_city()

void handle_edit_city ( struct connection pc,
const struct packet_edit_city *  packet 
)

Handle a request to change the internal state of a city.

Definition at line 715 of file edithand.cpp.

◆ handle_edit_city_create()

void handle_edit_city_create ( struct connection pc,
int  owner,
int  tile,
int  size,
int  tag 
)

Allows the editing client to create a city at the given position and of size 'size'.

Definition at line 654 of file edithand.cpp.

◆ handle_edit_city_remove()

void handle_edit_city_remove ( struct connection pc,
int  id 
)

Remove any city at the given location.

Definition at line 1258 of file edithand.cpp.

◆ handle_edit_game()

void handle_edit_game ( struct connection pc,
const struct packet_edit_game *  packet 
)

Handle edit requests to the main game data structure.

Definition at line 1396 of file edithand.cpp.

◆ handle_edit_mode()

void handle_edit_mode ( struct connection pc,
bool  is_edit_mode 
)

Handles a request by the client to enter edit mode.

Definition at line 175 of file edithand.cpp.

◆ handle_edit_player()

void handle_edit_player ( struct connection pc,
const struct packet_edit_player *  packet 
)

Handle editing of any or all player properties.

Definition at line 971 of file edithand.cpp.

◆ handle_edit_player_create()

void handle_edit_player_create ( struct connection pc,
int  tag 
)

Handle a request to create a new player.

Definition at line 879 of file edithand.cpp.

◆ handle_edit_player_remove()

void handle_edit_player_remove ( struct connection pc,
int  id 
)

Handle a request to remove a player.

Definition at line 947 of file edithand.cpp.

◆ handle_edit_player_vision()

void handle_edit_player_vision ( struct connection pc,
int  plr_no,
int  tile,
bool  known,
int  size 
)

Handles vision editing requests from client.

Definition at line 1170 of file edithand.cpp.

◆ handle_edit_recalculate_borders()

void handle_edit_recalculate_borders ( struct connection pc)

Client editor requests us to recalculate borders.

Note that this does not necessarily extend borders to their maximum due to the way the borders code is written. This may be considered a feature or limitation.

Definition at line 1250 of file edithand.cpp.

◆ handle_edit_scenario_desc()

void handle_edit_scenario_desc ( struct connection pc,
const char *  scenario_desc 
)

Handle edit requests to scenario description.

Definition at line 1457 of file edithand.cpp.

◆ handle_edit_startpos()

void handle_edit_startpos ( struct connection pconn,
const struct packet_edit_startpos *  packet 
)

Create or remove a start position at a tile.

Definition at line 1318 of file edithand.cpp.

◆ handle_edit_startpos_full()

void handle_edit_startpos_full ( struct connection pconn,
const struct packet_edit_startpos_full *  packet 
)

Setup which nations can start at a start position.

Definition at line 1358 of file edithand.cpp.

◆ handle_edit_tile()

void handle_edit_tile ( struct connection pc,
const struct packet_edit_tile *  packet 
)

Handles tile information from the client, to make edits to tiles.

Definition at line 359 of file edithand.cpp.

◆ handle_edit_tile_extra()

void handle_edit_tile_extra ( struct connection pc,
int  tile,
int  id,
bool  removal,
int  eowner,
int  size 
)

Handle a request to change one or more tiles' extras.

The 'remove' argument controls whether to remove or add the given extra from the tile.

Definition at line 316 of file edithand.cpp.

◆ handle_edit_tile_terrain()

void handle_edit_tile_terrain ( struct connection pc,
int  tile,
Terrain_type_id  terrain,
int  size 
)

Handles a client request to change the terrain of the tile at the given x, y coordinates.

The 'size' parameter indicates that all tiles in a square of "radius" 'size' should be affected. So size=1 corresponds to the single tile case.

Definition at line 276 of file edithand.cpp.

◆ handle_edit_toggle_fogofwar()

void handle_edit_toggle_fogofwar ( struct connection pc,
int  plr_no 
)

Temporarily remove fog-of-war for the player with player number 'plr_no'.

This will only stay in effect while the server is in edit mode and the connection is editing. Has no effect if fog-of-war is disabled globally.

Definition at line 1285 of file edithand.cpp.

◆ handle_edit_unit()

void handle_edit_unit ( struct connection pc,
const struct packet_edit_unit *  packet 
)

Handles unit information from the client, to make edits to units.

Definition at line 579 of file edithand.cpp.

◆ handle_edit_unit_create()

void handle_edit_unit_create ( struct connection pc,
int  owner,
int  tile,
Unit_type_id  utid,
int  count,
int  tag 
)

Handle a request to create 'count' units of type 'utid' at the tile given by the x, y coordinates and owned by player with number 'owner'.

Definition at line 417 of file edithand.cpp.

◆ handle_edit_unit_remove()

void handle_edit_unit_remove ( struct connection pc,
int  owner,
int  tile,
Unit_type_id  utid,
int  count 
)

Remove 'count' units of type 'utid' owned by player number 'owner' at tile (x, y).

Definition at line 505 of file edithand.cpp.

◆ handle_edit_unit_remove_by_id()

void handle_edit_unit_remove_by_id ( struct connection pc,
Unit_type_id  id 
)

Handle a request to remove a unit given by its id.

Definition at line 562 of file edithand.cpp.

◆ handle_save_scenario()

void handle_save_scenario ( struct connection pc,
const char *  name 
)

Make scenario file out of current game.

Definition at line 1471 of file edithand.cpp.

Variable Documentation

◆ need_continents_reassigned

bool need_continents_reassigned = false
static

◆ unfogged_players

bool* unfogged_players
static