From: Mario Date: Sun, 15 Nov 2015 19:24:04 +0000 (+1000) Subject: Add an unfill mode to the fill tool X-Git-Tag: xonotic-v0.8.2~1654^2~3 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e35c81f78f9dca0a59da77c4d45c153c72a15626;p=xonotic%2Fxonotic-data.pk3dir.git Add an unfill mode to the fill tool --- diff --git a/qcsrc/common/minigames/minigame/bd.qc b/qcsrc/common/minigames/minigame/bd.qc index 78892cef2..d002adaff 100644 --- a/qcsrc/common/minigames/minigame/bd.qc +++ b/qcsrc/common/minigames/minigame/bd.qc @@ -285,14 +285,58 @@ void bd_fill_recurse(entity minigame, entity player, int thetype, int letter, in bd_fill_recurse(minigame, player, thetype, letter, number + 1); } +void bd_unfill_recurse(entity minigame, entity player, int thetype, int letter, int number) +{ + string pos = minigame_tile_buildname(letter,number); + if(!bd_valid_tile(pos)) + return; + + entity targ = bd_find_piece(minigame, pos, true); + entity piece = bd_find_piece(minigame, pos, false); + + if(targ && thetype == targ.bd_tiletype) + { + if(targ.netname) { strunzone(targ.netname); } + remove(targ); + } + else if(piece && thetype == piece.bd_tiletype) + { + if(piece.netname) { strunzone(piece.netname); } + remove(piece); + } + else return; + + bd_unfill_recurse(minigame, player, thetype, letter - 1, number); + bd_unfill_recurse(minigame, player, thetype, letter + 1, number); + bd_unfill_recurse(minigame, player, thetype, letter, number - 1); + bd_unfill_recurse(minigame, player, thetype, letter, number + 1); +} + void bd_do_fill(entity minigame, entity player, string dir, string thetile) { if(minigame.minigame_flags & BD_TURN_EDIT) { int thetype = stof(thetile); - if(!bd_canfill(thetype)) + entity targ = bd_find_piece(minigame, dir, true); + entity piece = bd_find_piece(minigame, dir, false); + + if(!bd_canfill(thetype) || (piece || targ)) + { + int killtype = 0; + + if(targ) { killtype = targ.bd_tiletype; } + if(piece) { killtype = piece.bd_tiletype; } + + if(killtype) + { + int letter = minigame_tile_letter(dir); + int number = minigame_tile_number(dir); + bd_unfill_recurse(minigame, player, killtype, letter, number); + } + return; + } int letter = minigame_tile_letter(dir); int number = minigame_tile_number(dir);