|
| 1 | +// Cortex SC2 Roleplaying Engine |
| 2 | +// Copyright (C) 2009-2011 <http://www.cortexrp.com/> |
| 3 | +// |
| 4 | +// This program is free software; you can redistribute it and/or modify |
| 5 | +// it under the terms of the GNU General Public License as published by |
| 6 | +// the Free Software Foundation; version 2 of the License. |
| 7 | +// |
| 8 | +// This program is distributed in the hope that it will be useful, |
| 9 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | +// GNU General Public License for more details. |
| 12 | + |
| 13 | +// This entire file's purpose would be useless if Blizzard |
| 14 | +// left us a viable way to detect when a unit died in a transport |
| 15 | +// >< |
| 16 | +// Bug report filed and ignored: http://us.battle.net/sc2/en/forum/topic/3811454102 |
| 17 | + |
| 18 | +string libcrtx_labelmgr_prefix = "labelmgr_id_"; |
| 19 | +int libcrtx_labelmgr_highId = -1; |
| 20 | + |
| 21 | +// Adds entry in dataTable for labelId -> unitHandle |
| 22 | +void libcrtx_labelmgr_addlabel(int labelId, unit unitHandle) |
| 23 | +{ |
| 24 | + if( labelId > libcrtx_labelmgr_highId ) { |
| 25 | + libcrtx_labelmgr_highId = labelId; |
| 26 | + } |
| 27 | + |
| 28 | + DataTableSetUnit(true, libcrtx_labelmgr_prefix + IntToString(labelId), unitHandle); |
| 29 | +} |
| 30 | + |
| 31 | +// Removes labels not tied to active units. |
| 32 | +void libcrtx_labelmgr_update() |
| 33 | +{ |
| 34 | + int i = -1; |
| 35 | + unit linkedUnit; |
| 36 | + |
| 37 | + while( i <= libcrtx_labelmgr_highId ) |
| 38 | + { |
| 39 | + linkedUnit = DataTableGetUnit(true, libcrtx_labelmgr_prefix + IntToString(i)); |
| 40 | + if( linkedUnit == null || !UnitIsAlive(linkedUnit) ) { |
| 41 | + DataTableValueRemove(true, libcrtx_labelmgr_prefix + IntToString(i)); |
| 42 | + if( TextTagVisible(i, 1) ) { |
| 43 | + TextTagDestroy(i); |
| 44 | + } |
| 45 | + } |
| 46 | + i += 1; |
| 47 | + } |
| 48 | +} |
0 commit comments