/** * @brief Toggles the jump point for the selected systems. */ static void uniedit_toggleJump( StarSystem *sys ) { int i, j, rm; StarSystem *isys, *target; for (i=0; i<uniedit_nsys; i++) { isys = uniedit_sys[i]; rm = 0; for (j=0; j<isys->njumps; j++) { target = isys->jumps[j].target; /* Target already exists, remove. */ if (target == sys) { uniedit_jumpRm( isys, sys ); uniedit_jumpRm( sys, isys ); rm = 1; break; } } /* Target doesn't exist, add. */ if (!rm) { uniedit_jumpAdd( isys, sys ); uniedit_jumpAdd( sys, isys ); } } /* Reconstruct jumps just in case. */ systems_reconstructJumps(); }
/** * @brief Adds a jump. * * @usage system.createJump( "sys", "target", bothway) -- Creates a regular jump. * * @luaparam name Name of the system in which to create the jump. * @luaparam target Name of the targeted system. * @luaparam bothway If true, create the return jump in the target system. * @luaparam known Whether the player should known the jump * @luafunc createJump( "sys", "target", bothway) */ static int systemL_createJump( lua_State *L ) { StarSystem *sys = luaL_validsystem(L, 1); StarSystem *target = luaL_validsystem(L, 2); int bothway = lua_toboolean(L, 3); int known = lua_toboolean(L, 4); int alreadyExists=0; int i; for (i=0;i<sys->njumps;i++) { if (sys->jumps[i].target==target) alreadyExists=1; } if (!alreadyExists) system_addJumpPoint(sys,target,0,0,-1,-1,1,0,0,1,known); if (bothway==1) { alreadyExists=0; for (i=0;i<target->njumps;i++) { if (target->jumps[i].target==sys) alreadyExists=1; } if (!alreadyExists) system_addJumpPoint(target,sys,0,0,-1,-1,1,0,0,1,known); } systems_reconstructJumps(); return 0; }
/** * @brief Closes the system editor widget. */ static void uniedit_close( unsigned int wid, char *wgt ) { /* Frees some memory. */ uniedit_deselect(); /* Reconstruct jumps. */ systems_reconstructJumps(); /* Close the window. */ window_close( wid, wgt ); }
/** * @brief Toggles the jump point for the selected systems. */ static void uniedit_toggleJump( StarSystem *sys ) { int i, j, rm; StarSystem *isys, *target; for (i=0; i<uniedit_nsys; i++) { isys = uniedit_sys[i]; rm = 0; for (j=0; j<isys->njumps; j++) { target = isys->jumps[j].target; /* Target already exists, remove. */ if (target == sys) { uniedit_jumpRm( isys, sys ); uniedit_jumpRm( sys, isys ); rm = 1; break; } } /* Target doesn't exist, add. */ if (!rm) { uniedit_jumpAdd( isys, sys ); uniedit_jumpAdd( sys, isys ); } } /* Reconstruct jumps just in case. */ systems_reconstructJumps(); /* Reconstruct universe presences. */ space_reconstructPresences(); if (conf.devautosave) { dsys_saveSystem( sys ); dsys_saveSystem( isys ); } /* Update sidebar text. */ uniedit_selectText(); }