Xonotic
bd.qc File Reference
#include "bd.qh"
+ Include dependency graph for bd.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void bd_activate_editor (entity minigame, entity player)
 
bool bd_canfill (int ttype)
 
void bd_check_winner (entity minig)
 
void bd_close_editor (entity minigame, entity player)
 
void bd_controller_update (entity controller, int number)
 
int bd_dir_fromname (string bdir)
 
void bd_do_fill (entity minigame, entity player, string dir, string thetile)
 
void bd_do_move (entity minigame, entity player, string dir, string thetile, string thedir)
 
void bd_do_next_match (entity minigame, entity player)
 
void bd_editor_place (entity minigame, entity player, string pos, int thetile, string thedir)
 
void bd_fill_recurse (entity minigame, entity player, int thetype, int letter, int number)
 
entity bd_find_controller (entity minig, int letter)
 
entity bd_find_dozer (entity minig)
 
entity bd_find_piece (entity minig, string tile, bool check_target)
 
int bd_fix_dir (vector dir)
 
vector bd_get_dir (int bdir)
 
string bd_get_dir_name (int bdir)
 
void bd_load_level (entity minigame)
 
void bd_load_piece (entity minigame, string s)
 
void bd_move (entity minigame, entity player, string dir)
 
bool bd_move_dozer (entity minigame, entity dozer)
 
void bd_next_match (entity minigame, entity player, string next)
 
void bd_reset_moves (entity minigame)
 
void bd_restart_match (entity minigame, entity player)
 
string bd_save_controller_piece (entity minigame, entity e, int number)
 
bool bd_save_level (entity minigame)
 
string bd_save_piece (entity minigame, entity e)
 
void bd_set_next_match (entity minigame, string next)
 
void bd_set_nextlevel (entity minigame, string s)
 
void bd_setup_pieces (entity minigame)
 
void bd_unfill_recurse (entity minigame, entity player, int thetype, int letter, int number)
 
bool bd_valid_tile (string tile)
 
 REGISTER_MINIGAME (bd, _("Bulldozer"))
 

Variables

int bd_dir
 
const int BD_DIR_DN = 1
 
const int BD_DIR_LF = 2
 
const int BD_DIR_RT = 3
 
const int BD_DIR_UP = 0
 
int bd_dirs [BD_NUM_CNT]
 
const int BD_LET_CNT = 20
 
string bd_levelname
 
int bd_moves
 
string bd_nextlevel
 
const int BD_NUM_CNT = 20
 
const int BD_SF_PLAYERMOVES = MINIG_SF_CUSTOM
 
const int BD_SF_UPDATE_ALL = MINIG_SF_CUSTOM<<2
 
const int BD_SF_UPDATE_SINGLE = MINIG_SF_CUSTOM<<1
 
const int BD_SPECTATOR_TEAM = 255
 
const int BD_TEAMS = 1
 
const int BD_TILE_BOULDER = 3
 
const int BD_TILE_BRICK1 = 4
 
const int BD_TILE_BRICK2 = 5
 
const int BD_TILE_BRICK3 = 6
 
const int BD_TILE_BRICK4 = 7
 
const int BD_TILE_BRICK5 = 8
 
const int BD_TILE_BRICK6 = 9
 
const int BD_TILE_BRICK7 = 10
 
const int BD_TILE_BRICK8 = 11
 
const int BD_TILE_DOZER = 1
 
const int BD_TILE_LAST = 11
 
const int BD_TILE_SIZE = 20
 
const int BD_TILE_TARGET = 2
 
int bd_tilelet
 
int bd_tiletype
 
int bd_tiletypes [BD_NUM_CNT]
 
const int BD_TURN_EDIT = 0x0800
 
const int BD_TURN_LOSS = 0x0400
 
const int BD_TURN_MOVE = 0x0100
 
const int BD_TURN_TYPE = 0x0f00
 
const int BD_TURN_WIN = 0x0200
 

Function Documentation

◆ bd_activate_editor()

void bd_activate_editor ( entity  minigame,
entity  player 
)

Definition at line 632 of file bd.qc.

References bd_reset_moves(), bd_setup_pieces(), BD_TURN_EDIT, MINIG_SF_UPDATE, minigame_server_sendflags(), and sprint().

Referenced by bd_close_editor().

633 {
634 #ifdef SVQC
635  if(!player.minigame_players.bd_canedit)
636  {
637  sprint(player.minigame_players, "You're not allowed to edit levels, sorry!\n");
638  return;
639  }
640 #endif
641 
642  minigame.minigame_flags = BD_TURN_EDIT;
644 
645  bd_reset_moves(minigame);
646 
647  bd_setup_pieces(minigame);
648 }
void minigame_server_sendflags(entity ent, int mgflags)
Definition: minigames.qc:78
void bd_reset_moves(entity minigame)
Definition: bd.qc:547
const int MINIG_SF_UPDATE
Definition: minigames.qh:109
const int BD_TURN_EDIT
Definition: bd.qc:9
void bd_setup_pieces(entity minigame)
Definition: bd.qc:564
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_canfill()

bool bd_canfill ( int  ttype)

Definition at line 235 of file bd.qc.

References BD_TILE_BRICK1, BD_TILE_BRICK2, BD_TILE_BRICK3, BD_TILE_BRICK4, BD_TILE_BRICK5, BD_TILE_BRICK6, BD_TILE_BRICK7, and BD_TILE_BRICK8.

Referenced by bd_do_fill(), bd_editor_place(), and bd_load_piece().

236 {
237  switch(ttype)
238  {
239  case BD_TILE_BRICK8:
240  case BD_TILE_BRICK7:
241  case BD_TILE_BRICK6:
242  case BD_TILE_BRICK5:
243  case BD_TILE_BRICK4:
244  case BD_TILE_BRICK3:
245  case BD_TILE_BRICK2:
246  case BD_TILE_BRICK1: return true;
247  }
248 
249  return false;
250 }
const int BD_TILE_BRICK1
Definition: bd.qc:48
const int BD_TILE_BRICK6
Definition: bd.qc:53
const int BD_TILE_BRICK4
Definition: bd.qc:51
const int BD_TILE_BRICK8
Definition: bd.qc:55
const int BD_TILE_BRICK2
Definition: bd.qc:49
const int BD_TILE_BRICK5
Definition: bd.qc:52
const int BD_TILE_BRICK3
Definition: bd.qc:50
const int BD_TILE_BRICK7
Definition: bd.qc:54
+ Here is the caller graph for this function:

◆ bd_check_winner()

void bd_check_winner ( entity  minig)

Definition at line 178 of file bd.qc.

References bd_find_piece(), BD_TURN_WIN, entity(), findentity(), MINIG_SF_UPDATE, minigame_server_sendflags(), NULL, and owner.

Referenced by bd_move().

179 {
180  int total = 0, valid = 0;
181  entity e = NULL;
182  while ( ( e = findentity(e,owner,minig) ) )
183  if ( e.classname == "minigame_board_piece" && e.bd_tiletype == BD_TILE_TARGET )
184  {
185  ++total;
186  if(bd_find_piece(minig, e.netname, false).bd_tiletype == BD_TILE_BOULDER)
187  ++valid;
188  }
189 
190  if(valid >= total)
191  {
192  minig.minigame_flags = BD_TURN_WIN;
194  }
195 }
void minigame_server_sendflags(entity ent, int mgflags)
Definition: minigames.qc:78
entity bd_find_piece(entity minig, string tile, bool check_target)
Definition: bd.qc:68
entity() spawn
const int BD_TILE_TARGET
Definition: bd.qc:46
const int BD_TILE_BOULDER
Definition: bd.qc:47
const int MINIG_SF_UPDATE
Definition: minigames.qh:109
entity owner
Definition: main.qh:73
#define NULL
Definition: post.qh:17
const int BD_TURN_WIN
Definition: bd.qc:7
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_close_editor()

void bd_close_editor ( entity  minigame,
entity  player 
)

Definition at line 817 of file bd.qc.

References active_minigame, argv(), bd_activate_editor(), BD_DIR_DN, BD_DIR_LF, BD_DIR_RT, BD_DIR_UP, bd_do_fill(), bd_do_move(), bd_find_dozer(), bd_find_piece(), bd_next_match(), BD_NUM_CNT, bd_restart_match(), bd_save_level(), bd_setup_pieces(), BD_SF_PLAYERMOVES, BD_SPECTATOR_TEAM, BD_TILE_BOULDER, BD_TILE_BRICK1, BD_TILE_BRICK2, BD_TILE_BRICK3, BD_TILE_BRICK4, BD_TILE_BRICK5, BD_TILE_BRICK6, BD_TILE_BRICK7, BD_TILE_BRICK8, BD_TILE_DOZER, BD_TILE_TARGET, BD_TURN_EDIT, BD_TURN_LOSS, BD_TURN_MOVE, BD_TURN_WIN, bd_valid_tile(), DRAWFLAG_NORMAL, entity(), findentity(), FOREACH_MINIGAME_ENTITY, hud_fontsize, int, LOG_INFO, M_PI, MINIG_SF_UPDATE, minigame_count_players(), minigame_drawpic_centered(), minigame_hud_denormalize(), minigame_hud_denormalize_size(), minigame_hud_fitsqare, minigame_hud_simpleboard(), minigame_server_sendflags(), minigame_texture(), minigame_tile_buildname(), minigame_tile_letter(), minigame_tile_number(), minigame_tile_pos(), NULL, number, owner, panel_fg_alpha, sprint(), strcpy, strfree, string_null, vector(), WriteByte(), and WriteShort().

818 {
819 #ifdef SVQC
820  if(!player.minigame_players.bd_canedit)
821  {
822  sprint(player.minigame_players, "You're not allowed to edit levels, sorry!\n");
823  return;
824  }
825 #endif
826 
827  entity dozer = bd_find_dozer(minigame);
828  if(!dozer)
829  {
830  LOG_INFO("You need to place a bulldozer on the level to save it!");
831  return;
832  }
833 
834  if(bd_save_level(minigame))
835  {
836  minigame.minigame_flags = BD_TURN_MOVE;
838  }
839  else
840  {
841  LOG_INFO("You need to set the level name!");
842  return;
843  }
844 }
void minigame_server_sendflags(entity ent, int mgflags)
Definition: minigames.qc:78
entity() spawn
entity bd_find_dozer(entity minig)
Definition: bd.qc:104
const int MINIG_SF_UPDATE
Definition: minigames.qh:109
#define LOG_INFO(...)
Definition: log.qh:70
const int BD_TURN_MOVE
Definition: bd.qc:6
bool bd_save_level(entity minigame)
Definition: bd.qc:724
+ Here is the call graph for this function:

◆ bd_controller_update()

void bd_controller_update ( entity  controller,
int  number 
)

Definition at line 96 of file bd.qc.

References BD_SF_UPDATE_SINGLE, minigame_server_sendflags(), and number.

Referenced by bd_editor_place(), and bd_load_piece().

97 {
98 #ifdef SVQC
99  controller.bd_forceupdate = number;
100 #endif
102 }
void minigame_server_sendflags(entity ent, int mgflags)
Definition: minigames.qc:78
const int BD_SF_UPDATE_SINGLE
Definition: bd.qc:14
int int number
Definition: impulse.qc:89
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_dir_fromname()

int bd_dir_fromname ( string  bdir)

down

Definition at line 221 of file bd.qc.

References BD_DIR_DN, BD_DIR_LF, BD_DIR_RT, and BD_DIR_UP.

Referenced by bd_editor_place(), and bd_move().

222 {
223  if(bdir == "up" || bdir == "u")
224  return BD_DIR_UP; // up
225  if(bdir == "down" || bdir == "dn" || bdir == "d")
226  return BD_DIR_DN;
227  if(bdir == "left" || bdir == "lt" || bdir == "l")
228  return BD_DIR_LF; // left
229  if(bdir == "right" || bdir == "rt" || bdir == "r")
230  return BD_DIR_RT; // right
231 
232  return BD_DIR_DN; // down
233 }
const int BD_DIR_DN
Definition: bd.qc:59
const int BD_DIR_UP
Definition: bd.qc:58
const int BD_DIR_LF
Definition: bd.qc:60
const int BD_DIR_RT
Definition: bd.qc:61
+ Here is the caller graph for this function:

◆ bd_do_fill()

void bd_do_fill ( entity  minigame,
entity  player,
string  dir,
string  thetile 
)

Definition at line 506 of file bd.qc.

References bd_canfill(), bd_fill_recurse(), bd_find_piece(), BD_TURN_EDIT, bd_unfill_recurse(), entity(), minigame_tile_letter(), minigame_tile_number(), number, sprint(), and stof().

Referenced by bd_close_editor().

507 {
508 #ifdef SVQC
509  if(!player.minigame_players.bd_canedit)
510  {
511  sprint(player.minigame_players, "You're not allowed to edit levels, sorry!\n");
512  return;
513  }
514 #endif
515 
516  if(minigame.minigame_flags & BD_TURN_EDIT)
517  {
518  int thetype = stof(thetile);
519 
520  entity targ = bd_find_piece(minigame, dir, true);
521  entity piece = bd_find_piece(minigame, dir, false);
522 
523  if(!bd_canfill(thetype) || (piece || targ))
524  {
525  int killtype = 0;
526 
527  if(targ) { killtype = targ.bd_tiletype; }
528  if(piece) { killtype = piece.bd_tiletype; }
529 
530  if(killtype)
531  {
532  int letter = minigame_tile_letter(dir);
534  bd_unfill_recurse(minigame, player, killtype, letter, number);
535  }
536 
537  return;
538  }
539 
540  int letter = minigame_tile_letter(dir);
542 
543  bd_fill_recurse(minigame, player, thetype, letter, number);
544  }
545 }
int minigame_tile_number(string id)
Definition: minigames.qc:21
entity bd_find_piece(entity minig, string tile, bool check_target)
Definition: bd.qc:68
int int number
Definition: impulse.qc:89
entity() spawn
void bd_fill_recurse(entity minigame, entity player, int thetype, int letter, int number)
Definition: bd.qc:463
const int BD_TURN_EDIT
Definition: bd.qc:9
int minigame_tile_letter(string id)
Definition: minigames.qc:12
bool bd_canfill(int ttype)
Definition: bd.qc:235
int dir
Definition: impulse.qc:89
void bd_unfill_recurse(entity minigame, entity player, int thetype, int letter, int number)
Definition: bd.qc:479
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_do_move()

void bd_do_move ( entity  minigame,
entity  player,
string  dir,
string  thetile,
string  thedir 
)

Definition at line 454 of file bd.qc.

References bd_editor_place(), bd_move(), BD_TURN_EDIT, BD_TURN_MOVE, and stof().

Referenced by bd_close_editor().

455 {
456  if(minigame.minigame_flags & BD_TURN_MOVE)
457  bd_move(minigame, player, dir);
458 
459  if(minigame.minigame_flags & BD_TURN_EDIT)
460  bd_editor_place(minigame, player, dir, stof(thetile), thedir);
461 }
void bd_editor_place(entity minigame, entity player, string pos, int thetile, string thedir)
Definition: bd.qc:382
const int BD_TURN_EDIT
Definition: bd.qc:9
void bd_move(entity minigame, entity player, string dir)
Definition: bd.qc:339
const int BD_TURN_MOVE
Definition: bd.qc:6
int dir
Definition: impulse.qc:89
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_do_next_match()

void bd_do_next_match ( entity  minigame,
entity  player 
)

Definition at line 593 of file bd.qc.

References bd_reset_moves(), bd_setup_pieces(), BD_TURN_MOVE, MINIG_SF_UPDATE, minigame_server_sendflags(), and strcpy.

Referenced by bd_next_match().

594 {
595  minigame.minigame_flags = BD_TURN_MOVE;
597 
598  if(minigame.bd_nextlevel && minigame.bd_nextlevel != "")
599  {
600  strcpy(minigame.bd_levelname, minigame.bd_nextlevel);
601  }
602 
603  bd_setup_pieces(minigame);
604 
605  bd_reset_moves(minigame);
606 }
void minigame_server_sendflags(entity ent, int mgflags)
Definition: minigames.qc:78
void bd_reset_moves(entity minigame)
Definition: bd.qc:547
const int MINIG_SF_UPDATE
Definition: minigames.qh:109
#define strcpy(this, s)
Definition: string.qh:49
const int BD_TURN_MOVE
Definition: bd.qc:6
void bd_setup_pieces(entity minigame)
Definition: bd.qc:564
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_editor_place()

void bd_editor_place ( entity  minigame,
entity  player,
string  pos,
int  thetile,
string  thedir 
)

Definition at line 382 of file bd.qc.

References bd_canfill(), bd_controller_update(), bd_dir_fromname(), bd_find_controller(), bd_find_piece(), BD_TURN_EDIT, bd_valid_tile(), entity(), MINIG_SF_UPDATE, minigame_server_sendflags(), minigame_tile_letter(), minigame_tile_number(), msle_spawn(), number, strfree, and strzone().

Referenced by bd_do_move(), and bd_fill_recurse().

383 {
384  if ( minigame.minigame_flags & BD_TURN_EDIT )
385  if ( pos && thetile )
386  {
387  if ( bd_valid_tile(pos) )
388  {
389  entity found_piece = bd_find_piece(minigame, pos, false);
390  entity targ = bd_find_piece(minigame, pos, true);
391 
392  if(found_piece.bd_tiletype == BD_TILE_DOZER && thedir != "")
393  {
394  string newdir = strtolower(thedir);
395  int bdir = bd_dir_fromname(newdir);
396 
397  found_piece.bd_dir = bdir;
398  minigame_server_sendflags(found_piece,MINIG_SF_UPDATE); // update anyway
399  return;
400  }
401 
402  //entity dozer = bd_find_dozer(minigame);
403  //if(dozer && thetile == BD_TILE_DOZER && pos != dozer.netname)
404  //return; // nice try
405 
406  int tlet = minigame_tile_letter(pos);
407  int tnum = minigame_tile_number(pos);
408  entity controller = bd_find_controller(minigame, tlet);
409  if(controller.bd_tiletypes[tnum])
410  {
411  controller.bd_tiletypes[tnum] = 0;
412  controller.bd_dirs[tnum] = 0;
413  bd_controller_update(controller, tnum);
414  return;
415  }
416 
417  if(found_piece || (targ && thetile != BD_TILE_BOULDER))
418  {
419  entity piece = bd_find_piece(minigame, pos, false);
420  if(!piece) piece = bd_find_piece(minigame, pos, true);
421  if(!piece)
422  return; // how?!
423 
424  strfree(piece.netname);
425  delete(piece);
427  return;
428  }
429 
430  if(bd_canfill(thetile))
431  {
432  int number = minigame_tile_number(pos);
433  int letter = minigame_tile_letter(pos);
434  entity controller = bd_find_controller(minigame, letter);
435  controller.bd_tiletypes[number] = thetile;
436  controller.bd_dirs[number] = 0;
437  bd_controller_update(controller, number);
438  }
439  else
440  {
441  entity piece = msle_spawn(minigame,new(minigame_board_piece));
442  piece.team = 1;
443  piece.netname = strzone(pos);
444  piece.bd_tiletype = thetile;
445  piece.bd_dir = 0;
447  }
448 
450  }
451  }
452 }
int minigame_tile_number(string id)
Definition: minigames.qc:21
void minigame_server_sendflags(entity ent, int mgflags)
Definition: minigames.qc:78
entity bd_find_piece(entity minig, string tile, bool check_target)
Definition: bd.qc:68
int int number
Definition: impulse.qc:89
entity msle_spawn(entity minigame_session, entity e)
Definition: minigames.qc:87
entity() spawn
void bd_controller_update(entity controller, int number)
Definition: bd.qc:96
entity bd_find_controller(entity minig, int letter)
Definition: bd.qc:77
const int BD_TILE_BOULDER
Definition: bd.qc:47
const int MINIG_SF_UPDATE
Definition: minigames.qh:109
int bd_dir_fromname(string bdir)
Definition: bd.qc:221
const int BD_TILE_DOZER
Definition: bd.qc:45
const int BD_TURN_EDIT
Definition: bd.qc:9
int minigame_tile_letter(string id)
Definition: minigames.qc:12
bool bd_canfill(int ttype)
Definition: bd.qc:235
bool bd_valid_tile(string tile)
Definition: bd.qc:87
#define strfree(this)
Definition: string.qh:56
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_fill_recurse()

void bd_fill_recurse ( entity  minigame,
entity  player,
int  thetype,
int  letter,
int  number 
)

Definition at line 463 of file bd.qc.

References bd_editor_place(), bd_find_piece(), bd_valid_tile(), and minigame_tile_buildname().

Referenced by bd_do_fill().

464 {
465  string pos = minigame_tile_buildname(letter,number);
466  if(!bd_valid_tile(pos))
467  return;
468  if(bd_find_piece(minigame, pos, false) || bd_find_piece(minigame, pos, true))
469  return;
470 
471  bd_editor_place(minigame, player, pos, thetype, "");
472 
473  bd_fill_recurse(minigame, player, thetype, letter - 1, number);
474  bd_fill_recurse(minigame, player, thetype, letter + 1, number);
475  bd_fill_recurse(minigame, player, thetype, letter, number - 1);
476  bd_fill_recurse(minigame, player, thetype, letter, number + 1);
477 }
void bd_editor_place(entity minigame, entity player, string pos, int thetile, string thedir)
Definition: bd.qc:382
entity bd_find_piece(entity minig, string tile, bool check_target)
Definition: bd.qc:68
int int number
Definition: impulse.qc:89
void bd_fill_recurse(entity minigame, entity player, int thetype, int letter, int number)
Definition: bd.qc:463
string minigame_tile_buildname(int letter, int number)
Definition: minigames.qc:34
bool bd_valid_tile(string tile)
Definition: bd.qc:87
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_find_controller()

entity bd_find_controller ( entity  minig,
int  letter 
)

Definition at line 77 of file bd.qc.

References entity(), findentity(), NULL, and owner.

Referenced by bd_editor_place(), bd_load_piece(), and bd_move_dozer().

78 {
79  entity e = NULL;
80  while ( ( e = findentity(e,owner,minig) ) )
81  if ( e.classname == "bd_controller" && e.bd_tilelet == letter )
82  return e;
83  return NULL;
84 }
entity() spawn
entity owner
Definition: main.qh:73
#define NULL
Definition: post.qh:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_find_dozer()

entity bd_find_dozer ( entity  minig)

Definition at line 104 of file bd.qc.

References bd_dirs, BD_NUM_CNT, BD_SF_UPDATE_ALL, BD_SF_UPDATE_SINGLE, bd_tiletypes, classname, dir, entity(), findentity(), minigame_read_owner(), NET_HANDLE, NULL, number, owner, to, WriteByte(), and WriteString().

Referenced by bd_close_editor(), and bd_move().

105 {
106  entity e = NULL;
107  while ( ( e = findentity(e,owner,minig) ) )
108  if ( e.classname == "minigame_board_piece" && e.bd_tiletype == BD_TILE_DOZER )
109  return e;
110  return NULL;
111 }
entity() spawn
entity owner
Definition: main.qh:73
const int BD_TILE_DOZER
Definition: bd.qc:45
#define NULL
Definition: post.qh:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_find_piece()

entity bd_find_piece ( entity  minig,
string  tile,
bool  check_target 
)

Definition at line 68 of file bd.qc.

References entity(), findentity(), NULL, and owner.

Referenced by bd_check_winner(), bd_close_editor(), bd_do_fill(), bd_editor_place(), bd_fill_recurse(), bd_move_dozer(), and bd_unfill_recurse().

69 {
70  entity e = NULL;
71  while ( ( e = findentity(e,owner,minig) ) )
72  if ( e.classname == "minigame_board_piece" && e.netname == tile && ((check_target) ? e.bd_tiletype == BD_TILE_TARGET : e.bd_tiletype != BD_TILE_TARGET) )
73  return e;
74  return NULL;
75 }
entity() spawn
const int BD_TILE_TARGET
Definition: bd.qc:46
entity owner
Definition: main.qh:73
#define NULL
Definition: post.qh:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_fix_dir()

int bd_fix_dir ( vector  dir)

Definition at line 681 of file bd.qc.

References BD_DIR_DN, BD_DIR_LF, BD_DIR_RT, and BD_DIR_UP.

682 {
683  if(dir.x == 0 && dir.y == 1) { return BD_DIR_UP; } // up
684  if(dir.x == 0 && dir.y == -1) { return BD_DIR_DN; } // down
685  if(dir.x == -1 && dir.y == 0) { return BD_DIR_LF; } // left
686  if(dir.x == 1 && dir.y == 0) { return BD_DIR_RT; } // right
687 
688  return BD_DIR_DN; // down if all else fails
689 }
const int BD_DIR_DN
Definition: bd.qc:59
const int BD_DIR_UP
Definition: bd.qc:58
const int BD_DIR_LF
Definition: bd.qc:60
const int BD_DIR_RT
Definition: bd.qc:61
int dir
Definition: impulse.qc:89

◆ bd_get_dir()

vector bd_get_dir ( int  bdir)

Definition at line 197 of file bd.qc.

References BD_DIR_DN, BD_DIR_LF, BD_DIR_RT, and BD_DIR_UP.

Referenced by bd_move_dozer().

198 {
199  switch(bdir)
200  {
201  case BD_DIR_UP: return '0 1 0'; // up
202  default:
203  case BD_DIR_DN: return '0 -1 0'; // down
204  case BD_DIR_LF: return '-1 0 0'; // left
205  case BD_DIR_RT: return '1 0 0'; // right
206  }
207 }
const int BD_DIR_DN
Definition: bd.qc:59
const int BD_DIR_UP
Definition: bd.qc:58
const int BD_DIR_LF
Definition: bd.qc:60
const int BD_DIR_RT
Definition: bd.qc:61
+ Here is the caller graph for this function:

◆ bd_get_dir_name()

string bd_get_dir_name ( int  bdir)

Definition at line 209 of file bd.qc.

References BD_DIR_DN, BD_DIR_LF, BD_DIR_RT, and BD_DIR_UP.

210 {
211  switch(bdir)
212  {
213  case BD_DIR_UP: return "u"; // up
214  default:
215  case BD_DIR_DN: return "d"; // down
216  case BD_DIR_LF: return "l"; // left
217  case BD_DIR_RT: return "r"; // right
218  }
219 }
const int BD_DIR_DN
Definition: bd.qc:59
const int BD_DIR_UP
Definition: bd.qc:58
const int BD_DIR_LF
Definition: bd.qc:60
const int BD_DIR_RT
Definition: bd.qc:61

◆ bd_load_level()

void bd_load_level ( entity  minigame)

Definition at line 782 of file bd.qc.

References bd_load_piece(), bd_set_nextlevel(), fclose(), fgets(), FILE_READ, fopen(), LOG_INFO, strcat(), and substring().

Referenced by bd_reset_moves(), and bd_setup_pieces().

783 {
784  // loads all items from the database file
785  string file_read, file_name;
786  float file_get;
787 
788  file_name = strcat("minigames/bulldozer/storage_", minigame.bd_levelname, ".txt");
789  file_get = fopen(file_name, FILE_READ);
790  if(file_get < 0)
791  {
792  LOG_INFO("^3BULLDOZER: ^7could not find storage file ^3", file_name, "^7, no items were loaded");
793  }
794  else
795  {
796  for(;;)
797  {
798  file_read = fgets(file_get);
799  if(file_read == "")
800  break;
801  if(substring(file_read, 0, 2) == "//")
802  continue;
803  if(substring(file_read, 0, 1) == "#")
804  continue;
805  if(substring(file_read, 0, 9) == "nextlevel")
806  {
807  bd_set_nextlevel(minigame, file_read);
808  continue;
809  }
810 
811  bd_load_piece(minigame, file_read);
812  }
813  }
814  fclose(file_get);
815 }
const float FILE_READ
Definition: csprogsdefs.qc:231
void bd_set_nextlevel(entity minigame, string s)
Definition: bd.qc:674
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define LOG_INFO(...)
Definition: log.qh:70
void bd_load_piece(entity minigame, string s)
Definition: bd.qc:691
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_load_piece()

void bd_load_piece ( entity  minigame,
string  s 
)

Definition at line 691 of file bd.qc.

References argv(), bd_canfill(), bd_controller_update(), bd_find_controller(), dir, entity(), MINIG_SF_ALL, minigame_server_sendflags(), minigame_tile_letter(), minigame_tile_number(), msle_spawn(), number, stoi, strzone(), and tokenize_console.

Referenced by bd_load_level().

692 {
693  // separate pieces between the ; symbols
694  string bd_string = s;
695 
696  tokenize_console(bd_string);
697 
698  int argv_num = 0;
699  string tilename = strzone(argv(argv_num)); ++argv_num;
700  int tiletype = stoi(argv(argv_num)); ++argv_num;
701  int dir = stoi(argv(argv_num)); ++argv_num;
702 
703  if(bd_canfill(tiletype))
704  {
705  int letter = minigame_tile_letter(tilename);
706  int number = minigame_tile_number(tilename);
707  entity controller = bd_find_controller(minigame, letter);
708  controller.bd_tiletypes[number] = tiletype;
709  controller.bd_dirs[number] = dir;
710 
711  bd_controller_update(controller, number);
712  }
713  else
714  {
715  entity e = msle_spawn(minigame,new(minigame_board_piece));
716  e.netname = tilename;
717  e.team = 1;
718  e.bd_dir = dir;
719  e.bd_tiletype = tiletype;
721  }
722 }
int minigame_tile_number(string id)
Definition: minigames.qc:21
void minigame_server_sendflags(entity ent, int mgflags)
Definition: minigames.qc:78
const int MINIG_SF_ALL
Definition: minigames.qh:112
int int number
Definition: impulse.qc:89
entity msle_spawn(entity minigame_session, entity e)
Definition: minigames.qc:87
entity() spawn
void bd_controller_update(entity controller, int number)
Definition: bd.qc:96
entity bd_find_controller(entity minig, int letter)
Definition: bd.qc:77
#define stoi(s)
Definition: int.qh:4
int minigame_tile_letter(string id)
Definition: minigames.qc:12
#define tokenize_console
Definition: dpextensions.qh:24
bool bd_canfill(int ttype)
Definition: bd.qc:235
int dir
Definition: impulse.qc:89
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_move()

void bd_move ( entity  minigame,
entity  player,
string  dir 
)

Definition at line 339 of file bd.qc.

References bd_check_winner(), bd_dir_fromname(), bd_find_dozer(), bd_move_dozer(), BD_SF_PLAYERMOVES, BD_TURN_MOVE, entity(), findentity(), LOG_INFO, MINIG_SF_UPDATE, minigame_server_sendflags(), NULL, and owner.

Referenced by bd_do_move().

340 {
341  if ( minigame.minigame_flags & BD_TURN_MOVE )
342  if ( dir )
343  {
344  //if ( bd_valid_tile(pos) )
345  //if ( bd_find_piece(minigame, pos, false) )
346  {
347  entity dozer = bd_find_dozer(minigame);
348  if(!dozer)
349  {
350  LOG_INFO("Dozer wasn't found!");
351  return; // should not happen... TODO: end match?
352  }
353 
354  string thedir = strtolower(dir);
355  int bdir = bd_dir_fromname(thedir);
356 
357  int moved = 0;
358  entity e = NULL;
359  while ( ( e = findentity(e,owner,minigame) ) )
360  if ( e.classname == "minigame_board_piece" && e.bd_tiletype == BD_TILE_DOZER )
361  {
362  e.bd_dir = bdir;
363 
364  if(bd_move_dozer(minigame, e))
365  ++moved;
366 
367  minigame_server_sendflags(e,MINIG_SF_UPDATE); // update anyway
368  }
369 
370  if(moved)
371  player.bd_moves++;
372 
373  bd_check_winner(minigame);
374 
377  }
378  }
379 }
void minigame_server_sendflags(entity ent, int mgflags)
Definition: minigames.qc:78
entity() spawn
bool bd_move_dozer(entity minigame, entity dozer)
Definition: bd.qc:252
entity bd_find_dozer(entity minig)
Definition: bd.qc:104
const int MINIG_SF_UPDATE
Definition: minigames.qh:109
int bd_dir_fromname(string bdir)
Definition: bd.qc:221
entity owner
Definition: main.qh:73
const int BD_TILE_DOZER
Definition: bd.qc:45
#define NULL
Definition: post.qh:17
#define LOG_INFO(...)
Definition: log.qh:70
void bd_check_winner(entity minig)
Definition: bd.qc:178
const int BD_TURN_MOVE
Definition: bd.qc:6
int dir
Definition: impulse.qc:89
const int BD_SF_PLAYERMOVES
Definition: bd.qc:13
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_move_dozer()

bool bd_move_dozer ( entity  minigame,
entity  dozer 
)

Definition at line 252 of file bd.qc.

References bd_find_controller(), bd_find_piece(), bd_get_dir(), BD_TILE_BOULDER, BD_TILE_BRICK1, BD_TILE_BRICK2, BD_TILE_BRICK3, BD_TILE_BRICK4, BD_TILE_BRICK5, BD_TILE_BRICK6, BD_TILE_BRICK7, BD_TILE_BRICK8, BD_TILE_DOZER, bd_valid_tile(), dir, entity(), MINIG_SF_UPDATE, minigame_server_sendflags(), minigame_tile_buildname(), minigame_tile_letter(), minigame_tile_number(), number, strcpy, and vector().

Referenced by bd_move().

253 {
254  //if(!dozer.bd_dir)
255  //return false; // nope!
256 
257  int myx = minigame_tile_letter(dozer.netname);
258  int myy = minigame_tile_number(dozer.netname);
259 
260  vector dir = bd_get_dir(dozer.bd_dir);
261 
262  myx += dir.x;
263  myy += dir.y;
264 
265  string newpos = minigame_tile_buildname(myx, myy);
266  if(!bd_valid_tile(newpos))
267  return false;
268 
269  entity hit = bd_find_piece(minigame, newpos, false);
270 
271  if(hit)
272  switch(hit.bd_tiletype)
273  {
274  case BD_TILE_DOZER: // wtf, but let's do this incase
275  case BD_TILE_BRICK8:
276  case BD_TILE_BRICK7:
277  case BD_TILE_BRICK6:
278  case BD_TILE_BRICK5:
279  case BD_TILE_BRICK4:
280  case BD_TILE_BRICK3:
281  case BD_TILE_BRICK2:
282  case BD_TILE_BRICK1: return false;
283  case BD_TILE_BOULDER:
284  {
285  string testpos;
286  int tx = minigame_tile_letter(hit.netname);
287  int ty = minigame_tile_number(hit.netname);
288 
289  tx += dir.x;
290  ty += dir.y;
291 
292  testpos = minigame_tile_buildname(tx, ty);
293  if(!bd_valid_tile(testpos))
294  return false;
295  entity testhit = bd_find_piece(minigame, testpos, false);
296  if(testhit)
297  return false;
298 
299  entity controller = bd_find_controller(minigame, minigame_tile_letter(testpos));
300  int tnum = minigame_tile_number(testpos);
301  switch(controller.bd_tiletypes[tnum])
302  {
303  case BD_TILE_BRICK8:
304  case BD_TILE_BRICK7:
305  case BD_TILE_BRICK6:
306  case BD_TILE_BRICK5:
307  case BD_TILE_BRICK4:
308  case BD_TILE_BRICK3:
309  case BD_TILE_BRICK2:
310  case BD_TILE_BRICK1: return false;
311  }
312 
313  strcpy(hit.netname, testpos);
315  break;
316  }
317  }
318 
319  entity controller = bd_find_controller(minigame, minigame_tile_letter(newpos));
320  int number = minigame_tile_number(newpos);
321  switch(controller.bd_tiletypes[number])
322  {
323  case BD_TILE_BRICK8:
324  case BD_TILE_BRICK7:
325  case BD_TILE_BRICK6:
326  case BD_TILE_BRICK5:
327  case BD_TILE_BRICK4:
328  case BD_TILE_BRICK3:
329  case BD_TILE_BRICK2:
330  case BD_TILE_BRICK1: return false;
331  }
332 
333  strcpy(dozer.netname, newpos);
334 
335  return true;
336 }
int minigame_tile_number(string id)
Definition: minigames.qc:21
void minigame_server_sendflags(entity ent, int mgflags)
Definition: minigames.qc:78
entity bd_find_piece(entity minig, string tile, bool check_target)
Definition: bd.qc:68
int int number
Definition: impulse.qc:89
const int BD_TILE_BRICK1
Definition: bd.qc:48
entity() spawn
entity bd_find_controller(entity minig, int letter)
Definition: bd.qc:77
const int BD_TILE_BRICK6
Definition: bd.qc:53
const int BD_TILE_BOULDER
Definition: bd.qc:47
const int MINIG_SF_UPDATE
Definition: minigames.qh:109
vector bd_get_dir(int bdir)
Definition: bd.qc:197
const int BD_TILE_BRICK4
Definition: bd.qc:51
#define strcpy(this, s)
Definition: string.qh:49
const int BD_TILE_BRICK8
Definition: bd.qc:55
const int BD_TILE_DOZER
Definition: bd.qc:45
const int BD_TILE_BRICK2
Definition: bd.qc:49
int minigame_tile_letter(string id)
Definition: minigames.qc:12
const int BD_TILE_BRICK5
Definition: bd.qc:52
string minigame_tile_buildname(int letter, int number)
Definition: minigames.qc:34
vector(float skel, float bonenum) _skel_get_boneabs_hidden
bool bd_valid_tile(string tile)
Definition: bd.qc:87
const int BD_TILE_BRICK3
Definition: bd.qc:50
int dir
Definition: impulse.qc:89
const int BD_TILE_BRICK7
Definition: bd.qc:54
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_next_match()

void bd_next_match ( entity  minigame,
entity  player,
string  next 
)

Definition at line 613 of file bd.qc.

References bd_do_next_match(), bd_set_next_match(), BD_TURN_EDIT, and BD_TURN_WIN.

Referenced by bd_close_editor().

614 {
615  if(minigame.minigame_flags & BD_TURN_WIN)
616  bd_do_next_match(minigame, player);
617  if(minigame.minigame_flags & BD_TURN_EDIT)
618  bd_set_next_match(minigame, next);
619 }
void bd_set_next_match(entity minigame, string next)
Definition: bd.qc:608
const int BD_TURN_EDIT
Definition: bd.qc:9
const int BD_TURN_WIN
Definition: bd.qc:7
next
Definition: all.qh:88
void bd_do_next_match(entity minigame, entity player)
Definition: bd.qc:593
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_reset_moves()

void bd_reset_moves ( entity  minigame)

Definition at line 547 of file bd.qc.

References bd_load_level(), BD_SF_PLAYERMOVES, entity(), findentity(), minigame_server_sendflags(), NULL, and owner.

Referenced by bd_activate_editor(), bd_do_next_match(), and bd_restart_match().

548 {
549  entity e;
550 #ifdef SVQC
551  for(e = minigame.minigame_players; e; e = e.list_next)
552 #elif defined(CSQC)
553  e = NULL;
554  while( (e = findentity(e,owner,minigame)) )
555  if ( e.classname == "minigame_player" )
556 #endif
557  {
558  e.bd_moves = 0;
560  }
561 }
void minigame_server_sendflags(entity ent, int mgflags)
Definition: minigames.qc:78
entity() spawn
entity owner
Definition: main.qh:73
#define NULL
Definition: post.qh:17
const int BD_SF_PLAYERMOVES
Definition: bd.qc:13
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_restart_match()

void bd_restart_match ( entity  minigame,
entity  player 
)

Definition at line 622 of file bd.qc.

References bd_reset_moves(), bd_setup_pieces(), BD_TURN_MOVE, MINIG_SF_UPDATE, and minigame_server_sendflags().

Referenced by bd_close_editor().

623 {
624  minigame.minigame_flags = BD_TURN_MOVE;
626 
627  bd_setup_pieces(minigame);
628 
629  bd_reset_moves(minigame);
630 }
void minigame_server_sendflags(entity ent, int mgflags)
Definition: minigames.qc:78
void bd_reset_moves(entity minigame)
Definition: bd.qc:547
const int MINIG_SF_UPDATE
Definition: minigames.qh:109
const int BD_TURN_MOVE
Definition: bd.qc:6
void bd_setup_pieces(entity minigame)
Definition: bd.qc:564
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_save_controller_piece()

string bd_save_controller_piece ( entity  minigame,
entity  e,
int  number 
)

Definition at line 650 of file bd.qc.

References ftos(), minigame_tile_buildname(), and strcat().

Referenced by bd_save_level().

651 {
652  string bd_string = "";
653 
654  string tilename = minigame_tile_buildname(e.bd_tilelet, number);
655 
656  bd_string = strcat(bd_string, "\"", tilename, "\" ");
657  bd_string = strcat(bd_string, ftos(e.bd_tiletypes[number]), " ");
658  bd_string = strcat(bd_string, ftos(e.bd_dirs[number]));
659 
660  return bd_string;
661 }
int int number
Definition: impulse.qc:89
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
string minigame_tile_buildname(int letter, int number)
Definition: minigames.qc:34
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_save_level()

bool bd_save_level ( entity  minigame)

Definition at line 724 of file bd.qc.

References BD_NUM_CNT, bd_save_controller_piece(), bd_save_piece(), entity(), fclose(), fexists(), FILE_WRITE, findentity(), fopen(), fputs(), LOG_INFO, NULL, owner, and strcat().

Referenced by bd_close_editor().

725 {
726  if(minigame.bd_levelname && minigame.bd_levelname != "")
727  {
728  int target_count = 0, boulder_count = 0;
729  entity piece = NULL;
730  while((piece = findentity(piece,owner,minigame)))
731  if(piece.classname == "minigame_board_piece")
732  {
733  if(piece.bd_tiletype == BD_TILE_BOULDER)
734  ++boulder_count;
735  else if(piece.bd_tiletype == BD_TILE_TARGET)
736  ++target_count;
737  }
738 
739  if(boulder_count != target_count)
740  {
741  LOG_INFO("Not enough targets or boulders, fix your level!");
742  return false;
743  }
744 
745  // saves all objects to the database file
746  string file_name;
747  float file_get;
748 
749  file_name = strcat("minigames/bulldozer/storage_", minigame.bd_levelname, ".txt");
750  file_get = fopen(file_name, FILE_WRITE);
751  fputs(file_get, strcat("// bulldozer storage \"", minigame.bd_levelname, "\" last updated ", strftime(true, "%d-%m-%Y %H:%M:%S"), "\n"));
752 
753  if(minigame.bd_nextlevel && minigame.bd_nextlevel != "" && fexists(strcat("minigames/bulldozer/storage_", minigame.bd_nextlevel, ".txt")))
754  fputs(file_get, strcat("nextlevel = \"", minigame.bd_nextlevel, "\"\n"));
755 
756  entity e = NULL;
757  while ( ( e = findentity(e,owner,minigame) ) )
758  if ( e.classname == "bd_controller" )
759  {
760  for(int j = 0; j < BD_NUM_CNT; ++j)
761  {
762  // use a line of text for each object, listing all properties
763  fputs(file_get, strcat(bd_save_controller_piece(minigame, e, j), "\n"));
764  }
765  }
766  e = NULL;
767 
768  while ( ( e = findentity(e,owner,minigame) ) )
769  if ( e.classname == "minigame_board_piece" )
770  {
771  // use a line of text for each object, listing all properties
772  fputs(file_get, strcat(bd_save_piece(minigame, e), "\n"));
773  }
774  fclose(file_get);
775 
776  return true;
777  }
778 
779  return false;
780 }
entity() spawn
const int BD_TILE_TARGET
Definition: bd.qc:46
const int BD_TILE_BOULDER
Definition: bd.qc:47
entity owner
Definition: main.qh:73
string bd_save_piece(entity minigame, entity e)
Definition: bd.qc:663
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define NULL
Definition: post.qh:17
#define LOG_INFO(...)
Definition: log.qh:70
const float FILE_WRITE
Definition: csprogsdefs.qc:233
string bd_save_controller_piece(entity minigame, entity e, int number)
Definition: bd.qc:650
const int BD_NUM_CNT
Definition: bd.qc:19
ERASEABLE bool fexists(string f)
Definition: file.qh:4
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_save_piece()

string bd_save_piece ( entity  minigame,
entity  e 
)

Definition at line 663 of file bd.qc.

References ftos(), and strcat().

Referenced by bd_save_level().

664 {
665  string bd_string = "";
666 
667  bd_string = strcat(bd_string, "\"", e.netname, "\" ");
668  bd_string = strcat(bd_string, ftos(e.bd_tiletype), " ");
669  bd_string = strcat(bd_string, ftos(e.bd_dir));
670 
671  return bd_string;
672 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_set_next_match()

void bd_set_next_match ( entity  minigame,
string  next 
)

Definition at line 608 of file bd.qc.

References strcpy.

Referenced by bd_next_match().

609 {
610  strcpy(minigame.bd_nextlevel, next);
611 }
#define strcpy(this, s)
Definition: string.qh:49
next
Definition: all.qh:88
+ Here is the caller graph for this function:

◆ bd_set_nextlevel()

void bd_set_nextlevel ( entity  minigame,
string  s 
)

Definition at line 674 of file bd.qc.

References argv(), strcpy, and tokenize_console.

Referenced by bd_load_level().

675 {
676  tokenize_console(s);
677 
678  strcpy(minigame.bd_nextlevel, argv(2));
679 }
#define strcpy(this, s)
Definition: string.qh:49
#define tokenize_console
Definition: dpextensions.qh:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_setup_pieces()

void bd_setup_pieces ( entity  minigame)

Definition at line 564 of file bd.qc.

References BD_LET_CNT, bd_load_level(), entity(), findentity(), new_pure, NULL, owner, and strfree.

Referenced by bd_activate_editor(), bd_close_editor(), bd_do_next_match(), and bd_restart_match().

565 {
566  entity e = NULL;
567  while( (e = findentity(e, owner, minigame)) )
568  if(e.classname == "minigame_board_piece")
569  {
570  strfree(e.netname);
571  delete(e);
572  }
573  e = NULL;
574  while( (e = findentity(e, owner, minigame)) )
575  if(e.classname == "bd_controller")
576  {
577  delete(e);
578  }
579 
580  for(int letter = 0; letter < BD_LET_CNT; ++letter)
581  {
582  entity controller = new_pure(bd_controller);
583  controller.owner = minigame;
584  controller.bd_tilelet = letter;
585  #ifdef SVQC
586  Net_LinkEntity(controller, false, 0, bd_controller_send);
587  #endif
588  }
589 
590  bd_load_level(minigame);
591 }
entity() spawn
const int BD_LET_CNT
Definition: bd.qc:18
entity owner
Definition: main.qh:73
void bd_load_level(entity minigame)
Definition: bd.qc:782
#define NULL
Definition: post.qh:17
#define new_pure(class)
purely logical entities (.origin doesn&#39;t work)
Definition: oo.qh:62
#define strfree(this)
Definition: string.qh:56
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_unfill_recurse()

void bd_unfill_recurse ( entity  minigame,
entity  player,
int  thetype,
int  letter,
int  number 
)

Definition at line 479 of file bd.qc.

References bd_find_piece(), bd_valid_tile(), entity(), minigame_tile_buildname(), and strfree.

Referenced by bd_do_fill().

480 {
481  string pos = minigame_tile_buildname(letter,number);
482  if(!bd_valid_tile(pos))
483  return;
484 
485  entity targ = bd_find_piece(minigame, pos, true);
486  entity piece = bd_find_piece(minigame, pos, false);
487 
488  if(targ && thetype == targ.bd_tiletype)
489  {
490  strfree(targ.netname);
491  delete(targ);
492  }
493  else if(piece && thetype == piece.bd_tiletype)
494  {
495  strfree(piece.netname);
496  delete(piece);
497  }
498  else return;
499 
500  bd_unfill_recurse(minigame, player, thetype, letter - 1, number);
501  bd_unfill_recurse(minigame, player, thetype, letter + 1, number);
502  bd_unfill_recurse(minigame, player, thetype, letter, number - 1);
503  bd_unfill_recurse(minigame, player, thetype, letter, number + 1);
504 }
entity bd_find_piece(entity minig, string tile, bool check_target)
Definition: bd.qc:68
int int number
Definition: impulse.qc:89
entity() spawn
string minigame_tile_buildname(int letter, int number)
Definition: minigames.qc:34
bool bd_valid_tile(string tile)
Definition: bd.qc:87
#define strfree(this)
Definition: string.qh:56
void bd_unfill_recurse(entity minigame, entity player, int thetype, int letter, int number)
Definition: bd.qc:479
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bd_valid_tile()

bool bd_valid_tile ( string  tile)

Definition at line 87 of file bd.qc.

References BD_LET_CNT, minigame_tile_letter(), minigame_tile_number(), and number.

Referenced by bd_close_editor(), bd_editor_place(), bd_fill_recurse(), bd_move_dozer(), and bd_unfill_recurse().

88 {
89  if ( !tile )
90  return false;
91  int number = minigame_tile_number(tile);
92  int letter = minigame_tile_letter(tile);
93  return 0 <= number && number < BD_NUM_CNT && 0 <= letter && letter < BD_LET_CNT;
94 }
int minigame_tile_number(string id)
Definition: minigames.qc:21
int int number
Definition: impulse.qc:89
const int BD_LET_CNT
Definition: bd.qc:18
int minigame_tile_letter(string id)
Definition: minigames.qc:12
const int BD_NUM_CNT
Definition: bd.qc:19
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ REGISTER_MINIGAME()

REGISTER_MINIGAME ( bd  ,
_("Bulldozer")   
)

Variable Documentation

◆ bd_dir

int bd_dir

Definition at line 26 of file bd.qc.

◆ BD_DIR_DN

const int BD_DIR_DN = 1

Definition at line 59 of file bd.qc.

Referenced by bd_close_editor(), bd_dir_fromname(), bd_fix_dir(), bd_get_dir(), and bd_get_dir_name().

◆ BD_DIR_LF

const int BD_DIR_LF = 2

Definition at line 60 of file bd.qc.

Referenced by bd_close_editor(), bd_dir_fromname(), bd_fix_dir(), bd_get_dir(), and bd_get_dir_name().

◆ BD_DIR_RT

const int BD_DIR_RT = 3

Definition at line 61 of file bd.qc.

Referenced by bd_close_editor(), bd_dir_fromname(), bd_fix_dir(), bd_get_dir(), and bd_get_dir_name().

◆ BD_DIR_UP

const int BD_DIR_UP = 0

Definition at line 58 of file bd.qc.

Referenced by bd_close_editor(), bd_dir_fromname(), bd_fix_dir(), bd_get_dir(), and bd_get_dir_name().

◆ bd_dirs

int bd_dirs[BD_NUM_CNT]

Definition at line 28 of file bd.qc.

Referenced by bd_find_dozer().

◆ BD_LET_CNT

const int BD_LET_CNT = 20

Definition at line 18 of file bd.qc.

Referenced by bd_setup_pieces(), and bd_valid_tile().

◆ bd_levelname

string bd_levelname

Definition at line 34 of file bd.qc.

◆ bd_moves

int bd_moves

Definition at line 30 of file bd.qc.

◆ bd_nextlevel

string bd_nextlevel

Definition at line 35 of file bd.qc.

◆ BD_NUM_CNT

const int BD_NUM_CNT = 20

Definition at line 19 of file bd.qc.

Referenced by bd_close_editor(), bd_find_dozer(), and bd_save_level().

◆ BD_SF_PLAYERMOVES

const int BD_SF_PLAYERMOVES = MINIG_SF_CUSTOM

Definition at line 13 of file bd.qc.

Referenced by bd_close_editor(), bd_move(), and bd_reset_moves().

◆ BD_SF_UPDATE_ALL

const int BD_SF_UPDATE_ALL = MINIG_SF_CUSTOM<<2

Definition at line 15 of file bd.qc.

Referenced by bd_find_dozer().

◆ BD_SF_UPDATE_SINGLE

const int BD_SF_UPDATE_SINGLE = MINIG_SF_CUSTOM<<1

Definition at line 14 of file bd.qc.

Referenced by bd_controller_update(), and bd_find_dozer().

◆ BD_SPECTATOR_TEAM

const int BD_SPECTATOR_TEAM = 255

Definition at line 24 of file bd.qc.

Referenced by bd_close_editor().

◆ BD_TEAMS

const int BD_TEAMS = 1

Definition at line 23 of file bd.qc.

◆ BD_TILE_BOULDER

const int BD_TILE_BOULDER = 3

Definition at line 47 of file bd.qc.

Referenced by bd_close_editor(), and bd_move_dozer().

◆ BD_TILE_BRICK1

const int BD_TILE_BRICK1 = 4

Definition at line 48 of file bd.qc.

Referenced by bd_canfill(), bd_close_editor(), and bd_move_dozer().

◆ BD_TILE_BRICK2

const int BD_TILE_BRICK2 = 5

Definition at line 49 of file bd.qc.

Referenced by bd_canfill(), bd_close_editor(), and bd_move_dozer().

◆ BD_TILE_BRICK3

const int BD_TILE_BRICK3 = 6

Definition at line 50 of file bd.qc.

Referenced by bd_canfill(), bd_close_editor(), and bd_move_dozer().

◆ BD_TILE_BRICK4

const int BD_TILE_BRICK4 = 7

Definition at line 51 of file bd.qc.

Referenced by bd_canfill(), bd_close_editor(), and bd_move_dozer().

◆ BD_TILE_BRICK5

const int BD_TILE_BRICK5 = 8

Definition at line 52 of file bd.qc.

Referenced by bd_canfill(), bd_close_editor(), and bd_move_dozer().

◆ BD_TILE_BRICK6

const int BD_TILE_BRICK6 = 9

Definition at line 53 of file bd.qc.

Referenced by bd_canfill(), bd_close_editor(), and bd_move_dozer().

◆ BD_TILE_BRICK7

const int BD_TILE_BRICK7 = 10

Definition at line 54 of file bd.qc.

Referenced by bd_canfill(), bd_close_editor(), and bd_move_dozer().

◆ BD_TILE_BRICK8

const int BD_TILE_BRICK8 = 11

Definition at line 55 of file bd.qc.

Referenced by bd_canfill(), bd_close_editor(), and bd_move_dozer().

◆ BD_TILE_DOZER

const int BD_TILE_DOZER = 1

Definition at line 45 of file bd.qc.

Referenced by bd_close_editor(), and bd_move_dozer().

◆ BD_TILE_LAST

const int BD_TILE_LAST = 11

Definition at line 56 of file bd.qc.

◆ BD_TILE_SIZE

const int BD_TILE_SIZE = 20

Definition at line 21 of file bd.qc.

◆ BD_TILE_TARGET

const int BD_TILE_TARGET = 2

Definition at line 46 of file bd.qc.

Referenced by bd_close_editor().

◆ bd_tilelet

int bd_tilelet

Definition at line 32 of file bd.qc.

◆ bd_tiletype

int bd_tiletype

Definition at line 44 of file bd.qc.

◆ bd_tiletypes

int bd_tiletypes[BD_NUM_CNT]

Definition at line 42 of file bd.qc.

Referenced by bd_find_dozer().

◆ BD_TURN_EDIT

const int BD_TURN_EDIT = 0x0800

◆ BD_TURN_LOSS

const int BD_TURN_LOSS = 0x0400

Definition at line 8 of file bd.qc.

Referenced by bd_close_editor().

◆ BD_TURN_MOVE

const int BD_TURN_MOVE = 0x0100

Definition at line 6 of file bd.qc.

Referenced by bd_close_editor(), bd_do_move(), bd_do_next_match(), bd_move(), and bd_restart_match().

◆ BD_TURN_TYPE

const int BD_TURN_TYPE = 0x0f00

Definition at line 10 of file bd.qc.

◆ BD_TURN_WIN

const int BD_TURN_WIN = 0x0200

Definition at line 7 of file bd.qc.

Referenced by bd_check_winner(), bd_close_editor(), and bd_next_match().