@@ -267,97 +267,6 @@ SCP_vector<std::pair<SCP_string, bool>> LoadoutDialogModel::getWeaponEnablerVari
267267 return _weaponVarList;
268268}
269269
270- void LoadoutDialogModel::setShipInfo (SCP_string textIn, bool enabled, int extraAllocated, SCP_string varForCount)
271- {
272- bool found = false , previouslyEnabled;
273- int index = 0 ;
274-
275- for (auto & item : _teams[_currentTeam].ships ) {
276- if (textIn == Ship_info[item.infoIndex ].name ) {
277- previouslyEnabled = item.enabled ;
278- item.enabled = enabled;
279- item.extraAllocated = extraAllocated;
280- item.varCountIndex = get_index_sexp_variable_name (varForCount);
281- found = true ;
282-
283- // need to check if this ship will hold more than the last highest capacity
284- if (enabled) {
285- if (Ship_info[item.infoIndex ].num_primary_banks > _teams[_currentTeam].largestPrimaryBankCount ) {
286- _teams[_currentTeam].largestPrimaryBankCount = Ship_info[item.infoIndex ].num_primary_banks ;
287- }
288-
289- int capacity = 0 ;
290-
291- for (int i = 0 ; i < Ship_info[item.infoIndex ].num_secondary_banks ; i++){
292- capacity += Ship_info[item.infoIndex ].secondary_bank_ammo_capacity [i];
293- }
294-
295- if (capacity > _teams[_currentTeam].largestSecondaryCapacity ) {
296- _teams[_currentTeam].largestSecondaryCapacity = capacity;
297- }
298-
299- if (!previouslyEnabled && item.varCountIndex == -1 ) {
300- item.extraAllocated = _teams[_currentTeam].startingShipCount / 2 ;
301- }
302-
303- }
304-
305- // now that all the data is correctly set, rebuild the corresponding string.
306- _shipList[index].first = createItemString (true , false , index);
307- _shipList[index].second = enabled;
308-
309- break ;
310- }
311- index++;
312- }
313-
314- // rebuild the lists that the UI depends on.
315- buildCurrentLists ();
316- Assert (found);
317- modelChanged ();
318- }
319-
320- void LoadoutDialogModel::setWeaponInfo (SCP_string textIn, bool enabled, int extraAllocated, SCP_string varForCount)
321- {
322- bool found = false , previouslyEnabled;
323- int index = 0 ;
324-
325- for (auto & item : _teams[_currentTeam].weapons ) {
326- if (textIn == Weapon_info[item.infoIndex ].name ) {
327- previouslyEnabled = !item.enabled ;
328-
329- item.enabled = enabled;
330- item.extraAllocated = extraAllocated;
331- item.varCountIndex = get_index_sexp_variable_name (varForCount);
332-
333- if (item.varCountIndex == -1 && !previouslyEnabled)
334- {
335- if (Weapon_info[item.infoIndex ].subtype == WP_LASER) {
336- item.extraAllocated = (_teams[_currentTeam].startingShipCount * _teams[_currentTeam].largestPrimaryBankCount ) / 2 ;
337- }
338- else {
339- Assert (Weapon_info[item.infoIndex ].cargo_size > 0 );
340- item.extraAllocated = (_teams[_currentTeam].startingShipCount * _teams[_currentTeam].largestSecondaryCapacity ) / (2 * Weapon_info[item.infoIndex ].cargo_size );
341- }
342-
343- }
344-
345- // now that all the data is correctly set, rebuild the corresponding string.
346- _weaponList[index].first = createItemString (false , false , index);
347- _weaponList[index].second = enabled;
348-
349- found = true ;
350- break ;
351- }
352- index++;
353- }
354-
355- Assert (found);
356- buildCurrentLists ();
357-
358- modelChanged ();
359- }
360-
361270SCP_string LoadoutDialogModel::createItemString (bool ship, bool variable, int itemIndex, const char * variableIn)
362271{
363272 // Using a pointer here seems to lead to memory corruption, so I'll just use a temp Loadout Item
@@ -435,152 +344,6 @@ void LoadoutDialogModel::switchTeam(int teamIn)
435344 modelChanged ();
436345}
437346
438- void LoadoutDialogModel::setShipEnablerVariables (SCP_vector<SCP_string> variablesIn, bool enabled, int extraAllocated, SCP_string varForCount)
439- {
440- for (auto & nameIn : variablesIn) { // FIXME, this is trash
441- for (auto & variable : _shipVarList) {
442- if (nameIn == variable.first ) {
443- variable.second = enabled;
444- break ;
445- }
446- }
447- }
448-
449- // if they are enabled, we need to add them to the list.
450- if (enabled) {
451- for (auto & nameIn : variablesIn) {
452- bool found = false ;
453- for (auto & item : _teams[_currentTeam].varShips ) {
454-
455- // check to see if it was already added
456- if (item.name == nameIn) {
457- found = true ;
458- item.varCountIndex = get_index_sexp_variable_name (varForCount);
459- if (extraAllocated == 0 && item.varCountIndex == -1 ) {
460- item.extraAllocated = (int )((float )_teams[_currentTeam].startingShipCount / 2 .0f );
461-
462- // at least have 1
463- if (item.extraAllocated < 1 ) {
464- item.extraAllocated = 1 ;
465- }
466- }
467- else {
468- item.extraAllocated = extraAllocated;
469- }
470-
471- break ;
472- }
473- }
474-
475- if (!found) {
476- _teams[_currentTeam].varShips .emplace_back (
477- get_index_sexp_variable_name (nameIn),
478- true ,
479- false , // it cannot be required because this is var enabled
480- 0 , // there cannot be any because this is var enabled.
481- ShipVarDefault, // default o f.
482- -1 , // no var for count until one can be selected.
483- SCP_string (nameIn));
484- }
485- }
486-
487- } // if they are disabled, remove them.
488- else {
489- for (auto & nameIn : variablesIn) {
490- auto item = _teams[_currentTeam].varShips .begin ();
491- while (item != _teams[_currentTeam].varShips .end ()) {
492- // check to see if it was already added, and get rid of the info.
493- if (item->name == nameIn) {
494- item->enabled = false ;
495- item->extraAllocated = 0 ;
496- item->infoIndex = -1 ;
497- item->varCountIndex = get_index_sexp_variable_name (nameIn);
498- item->countInWings = 0 ;
499- break ;
500- }
501- }
502- }
503- }
504-
505- _spinBoxUpdateRequired = true ;
506- buildCurrentLists ();
507- modelChanged ();
508- }
509-
510- void LoadoutDialogModel::setWeaponEnablerVariables (SCP_vector<SCP_string> variablesIn, bool enabled, int extraAllocated, SCP_string varForCount)
511- {
512- for (auto & nameIn : variablesIn) {
513- for (auto & variable : _weaponVarList) {
514- if (nameIn == variable.first ) {
515- variable.second = enabled;
516- break ;
517- }
518- }
519- }
520-
521- // if they are enabled, we need to add them to the list.
522- if (enabled) {
523- for (auto & nameIn : variablesIn) {
524- bool found = false ;
525-
526- for (auto & item : _teams[_currentTeam].varWeapons ) {
527-
528- // check to see if it was already added
529- if (item.name == nameIn) {
530- found = true ;
531- item.varCountIndex = get_index_sexp_variable_name (varForCount);
532-
533- if (extraAllocated == 0 && item.varCountIndex == -1 ) {
534- item.extraAllocated = (int )((float )_teams[_currentTeam].startingShipCount / 2 .0f );
535-
536- // at least have 1
537- if (item.extraAllocated < 1 ) {
538- item.extraAllocated = 1 ;
539- }
540- }
541- else {
542- item.extraAllocated = extraAllocated;
543- }
544-
545- break ;
546- }
547- }
548-
549- if (!found) {
550- _teams[_currentTeam].varShips .emplace_back (
551- get_index_sexp_variable_name (nameIn),
552- true ,
553- false , // it cannot be required because it is var enabled
554- 0 , // there cannot be any because this is var enabled.
555- WeaponVarDefault * _teams[_currentTeam].startingShipCount ,
556- -1 , // no var for count until one can be selected.
557- SCP_string (nameIn));
558- }
559- }
560-
561- } // if they are disabled, remove them.
562- else {
563- for (auto & nameIn : variablesIn) {
564- auto item = _teams[_currentTeam].varWeapons .begin ();
565- while (item != _teams[_currentTeam].varWeapons .end ()) {
566- // check to see if it was already added, and get rid of the info.
567- if (item->name == nameIn) {
568- item->enabled = false ;
569- item->extraAllocated = 0 ;
570- item->infoIndex = -1 ;
571- item->varCountIndex = get_index_sexp_variable_name (nameIn);
572- item->countInWings = 0 ;
573- break ;
574- }
575- }
576- }
577- }
578-
579- _spinBoxUpdateRequired = true ;
580- buildCurrentLists ();
581- modelChanged ();
582- }
583-
584347bool LoadoutDialogModel::apply () {
585348
586349 int currentTeam = 0 ;
@@ -659,8 +422,9 @@ bool LoadoutDialogModel::apply() {
659422
660423
661424 Team_data[currentTeam].num_weapon_choices = index;
425+ Team_data[currentTeam].do_not_validate = modelTeam.skipValidation ;
662426 }
663-
427+
664428 Entry_delay_time = fl2f (_playerEntryDelay);
665429
666430
@@ -1170,6 +934,16 @@ void LoadoutDialogModel::setRequiredWeapon(const SCP_vector<SCP_string>& list, c
1170934 buildCurrentLists ();
1171935}
1172936
937+ bool LoadoutDialogModel::getSkipValidation () {
938+ return _teams[_currentTeam].skipValidation ;
939+ }
940+
941+ void LoadoutDialogModel::setSkipValidation (const bool skipIt) {
942+ // this is designed to be a global control, so turn this off in TvT, until we hear from someone otherwise.
943+ for (auto & team : _teams) {
944+ team.skipValidation = skipIt;
945+ }
946+ }
1173947
1174948}
1175949}
0 commit comments