function crossRef(units) {
                for (var id in units) {
                    var unit = units[id];
                    unit.id = id;
                    if (unit.build) {
                        for (var b = 0; b < unit.build.length; ++b) {
                            var ref = units[unit.build[b]];
                            if (!ref) {
                                ref = { id: unit.build[b] };
                                units[ref.id] = ref;
                            }
                            unit.build[b] = ref;
                        }
                    }
                    if (unit.projectiles) {
                        for (var p = 0; p < unit.projectiles.length; ++p) {
                            var ref = units[unit.projectiles[p]];
                            if (!ref) {
                                ref = { id: unit.projectiles[p] };
                                units[ref.id] = ref;
                            }
                            unit.projectiles[p] = ref;
                        }
                    }
                }
            }
// Fix up cross-unit references
Fix up cross-unit references
Fix up cross - unit references
function crossRef(units) {
                for (var id in units) {
                    var unit = units[id];
                    unit.id = id;
                    if (unit.build) {
                        for (var b = 0; b < unit.build.length; ++b) {
                            var ref = units[unit.build[b]];
                            if (!ref) {
                                ref = { id: unit.build[b] };
                                units[ref.id] = ref;
                            }
                            unit.build[b] = ref;
                        }
                    }
                    if (unit.projectiles) {
                        for (var p = 0; p < unit.projectiles.length; ++p) {
                            var ref = units[unit.projectiles[p]];
                            if (!ref) {
                                ref = { id: unit.projectiles[p] };
                                units[ref.id] = ref;
                            }
                            unit.projectiles[p] = ref;
                        }
                    }
                }
            }
function crossRef ( units ) { for ( var id in units ) { var unit = units [ id ] ; unit . id = id ; if ( unit . build ) { for ( var b = 0 ; b < unit . build . length ; ++ b ) { var ref = units [ unit . build [ b ] ] ; if ( ! ref ) { ref = { id : unit . build [ b ] } ; units [ ref . id ] = ref ; } unit . build [ b ] = ref ; } } if ( unit . projectiles ) { for ( var p = 0 ; p < unit . projectiles . length ; ++ p ) { var ref = units [ unit . projectiles [ p ] ] ; if ( ! ref ) { ref = { id : unit . projectiles [ p ] } ; units [ ref . id ] = ref ; } unit . projectiles [ p ] = ref ; } } } }
Fix up cross-unit references
Fix up cross - unit references