Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.23 KB | None | 0 0
  1. Index: fred2/initialstatus.cpp
  2. ===================================================================
  3. --- fred2/initialstatus.cpp (revision 9274)
  4. +++ fred2/initialstatus.cpp (working copy)
  5. @@ -379,7 +379,7 @@
  6. GetDlgItem(IDC_HULL)->SetWindowText("");
  7.  
  8. if (objp != NULL) {
  9. - if (objp->type == OBJ_SHIP) {
  10. + if (objp->type == OBJ_SHIP || objp->type == OBJ_START) {
  11. ship* shipp = &Ships[objp->instance];
  12. int i = 0;
  13.  
  14. Index: fred2/sexp_tree.cpp
  15. ===================================================================
  16. --- fred2/sexp_tree.cpp (revision 9274)
  17. +++ fred2/sexp_tree.cpp (working copy)
  18. @@ -45,6 +45,7 @@
  19. #include "graphics/gropenglshader.h"
  20. #include "graphics/gropenglpostprocessing.h"
  21. #include "sound/ds.h"
  22. +#include "globalincs/alphacolors.h"
  23.  
  24. #define TREE_NODE_INCREMENT 100
  25.  
  26. @@ -4395,6 +4396,10 @@
  27. list = get_listing_opf_mission_moods();
  28. break;
  29.  
  30. + case OPF_TEAM_COLOR:
  31. + list = get_listing_opf_team_colors();
  32. + break;
  33. +
  34. default:
  35. Int3(); // unknown OPF code
  36. list = NULL;
  37. @@ -5877,8 +5882,18 @@
  38. return head.next;
  39. }
  40.  
  41. +sexp_list_item *sexp_tree::get_listing_opf_team_colors()
  42. +{
  43. + sexp_list_item head;
  44. + for (SCP_map<SCP_string, team_color>::iterator tcolor = Team_Colors.begin(); tcolor != Team_Colors.end(); ++tcolor) {
  45. + head.add_data_dup(tcolor->first.c_str());
  46. + }
  47.  
  48. + return head.next;
  49. +}
  50.  
  51. +
  52. +
  53. // Deletes sexp_variable from sexp_tree.
  54. // resets tree to not include given variable, and resets text and type
  55. void sexp_tree::delete_sexp_tree_variable(const char *var_name)
  56. Index: fred2/sexp_tree.h
  57. ===================================================================
  58. --- fred2/sexp_tree.h (revision 9274)
  59. +++ fred2/sexp_tree.h (working copy)
  60. @@ -268,6 +268,7 @@
  61. sexp_list_item *get_listing_opf_ship_effect();
  62. sexp_list_item *get_listing_opf_animation_type();
  63. sexp_list_item *get_listing_opf_mission_moods();
  64. + sexp_list_item *get_listing_opf_team_colors();
  65.  
  66. int m_mode;
  67. int item_index;
  68. Index: graphics/2d.h
  69. ===================================================================
  70. --- graphics/2d.h (revision 9274)
  71. +++ graphics/2d.h (working copy)
  72. @@ -88,6 +88,8 @@
  73. } stripe;
  74. } team_color;
  75.  
  76. +
  77. +
  78. typedef struct tsb_t {
  79. vec3d tangent;
  80. float scaler;
  81. @@ -508,7 +510,7 @@
  82.  
  83. void (*gf_flush_data_states)();
  84.  
  85. - void (*gf_set_team_color)(SCP_string team);
  86. + void (*gf_set_team_color)(SCP_string team, SCP_string secondaryteam, fix timestamp, int fadetime);
  87. void (*gf_enable_team_color)();
  88. void (*gf_disable_team_color)();
  89.  
  90. Index: graphics/gropengltnl.cpp
  91. ===================================================================
  92. --- graphics/gropengltnl.cpp (revision 9274)
  93. +++ graphics/gropengltnl.cpp (working copy)
  94. @@ -15,6 +15,7 @@
  95. #include "globalincs/pstypes.h"
  96. #include "globalincs/def_files.h"
  97. #include "globalincs/alphacolors.h"
  98. +#include "globalincs/systemvars.h"
  99.  
  100. #include "graphics/2d.h"
  101. #include "lighting/lighting.h"
  102. @@ -70,6 +71,7 @@
  103. int Buffer_sdr = -1;
  104.  
  105. team_color* Current_team_color;
  106. +team_color Current_temp_color;
  107. bool Using_Team_Color = false;
  108.  
  109. struct opengl_vertex_buffer {
  110. @@ -473,14 +475,40 @@
  111. opengl_destroy_all_buffers();
  112. }
  113.  
  114. -void gr_opengl_set_team_color(SCP_string team) {
  115. - if (Team_Colors.find(team) != Team_Colors.end()) {
  116. - Current_team_color = &Team_Colors[team];
  117. - Using_Team_Color = true;
  118. - } else
  119. - Using_Team_Color = false;
  120. +void mix_two_team_colors(team_color* dest, team_color* a, team_color* b, float mix_factor) {
  121. + dest->base.r = a->base.r * (1.0f - mix_factor) + b->base.r * mix_factor;
  122. + dest->base.g = a->base.g * (1.0f - mix_factor) + b->base.g * mix_factor;
  123. + dest->base.b = a->base.b * (1.0f - mix_factor) + b->base.b * mix_factor;
  124. +
  125. + dest->stripe.r = a->stripe.r * (1.0f - mix_factor) + b->stripe.r * mix_factor;
  126. + dest->stripe.g = a->stripe.g * (1.0f - mix_factor) + b->stripe.g * mix_factor;
  127. + dest->stripe.b = a->stripe.b * (1.0f - mix_factor) + b->stripe.b * mix_factor;
  128. }
  129.  
  130. +void gr_opengl_set_team_color(SCP_string team, SCP_string secondaryteam, fix timestamp, int fadetime) {
  131. + if (secondaryteam == "<none>") {
  132. + if (Team_Colors.find(team) != Team_Colors.end()) {
  133. + Current_team_color = &Team_Colors[team];
  134. + Using_Team_Color = true;
  135. + } else
  136. + Using_Team_Color = false;
  137. + } else {
  138. + if (Team_Colors.find(team) != Team_Colors.end() && Team_Colors.find(secondaryteam) != Team_Colors.end()) {
  139. + team_color temp_color;
  140. + team_color start = Team_Colors[team];
  141. + team_color end = Team_Colors[secondaryteam];
  142. + float time_remaining = (f2fl(Missiontime - timestamp) * 1000)/fadetime;
  143. + CLAMP(time_remaining, 0.0f, 1.0f);
  144. + mix_two_team_colors(&temp_color, &start, &end, time_remaining);
  145. +
  146. + Current_temp_color = temp_color;
  147. + Current_team_color = &Current_temp_color;
  148. + Using_Team_Color = true;
  149. + } else
  150. + Using_Team_Color = false;
  151. + }
  152. +}
  153. +
  154. void gr_opengl_disable_team_color() {
  155. Using_Team_Color = false;
  156. }
  157. Index: graphics/gropengltnl.h
  158. ===================================================================
  159. --- graphics/gropengltnl.h (revision 9274)
  160. +++ graphics/gropengltnl.h (working copy)
  161. @@ -56,7 +56,7 @@
  162. int gr_opengl_end_state_block();
  163. void gr_opengl_set_state_block(int);
  164.  
  165. -void gr_opengl_set_team_color(SCP_string team);
  166. +void gr_opengl_set_team_color(SCP_string team, SCP_string secondaryteam = "<none>", fix timestamp = 0, int fadetime = 0);
  167. void gr_opengl_disable_team_color();
  168.  
  169. void opengl_tnl_shutdown();
  170. Index: graphics/grstub.cpp
  171. ===================================================================
  172. --- graphics/grstub.cpp (revision 9274)
  173. +++ graphics/grstub.cpp (working copy)
  174. @@ -697,7 +697,7 @@
  175. return -1;
  176. }
  177.  
  178. -void gr_stub_set_team_color(SCP_string team) {
  179. +void gr_stub_set_team_color(SCP_string team,SCP_string secondaryteam, fix timestamp, int fadetime) {
  180. }
  181.  
  182. void gr_stub_enable_team_color() {
  183. Index: hud/hudtargetbox.cpp
  184. ===================================================================
  185. --- hud/hudtargetbox.cpp (revision 9274)
  186. +++ hud/hudtargetbox.cpp (working copy)
  187. @@ -544,7 +544,7 @@
  188. model_set_outline_color_fast(iff_get_color_by_team_and_object(target_shipp->team, Player_ship->team, 1, target_objp));
  189.  
  190. if (Ship_info[Ships[target_objp->instance].ship_info_index].uses_team_colors) {
  191. - gr_set_team_color(Ships[target_objp->instance].team_name);
  192. + gr_set_team_color(Ships[target_objp->instance].team_name, Ships[target_objp->instance].secondary_team_name, Ships[target_objp->instance].team_change_timestamp, Ships[target_objp->instance].team_change_time);
  193. }
  194.  
  195. flags = (Cmdline_nohtl) ? MR_SHOW_OUTLINE : MR_SHOW_OUTLINE_HTL;
  196. Index: lab/lab.cpp
  197. ===================================================================
  198. --- lab/lab.cpp (revision 9274)
  199. +++ lab/lab.cpp (working copy)
  200. @@ -110,6 +110,8 @@
  201. static int Trackball_mode = 1;
  202. static int Trackball_active = 0;
  203.  
  204. +SCP_string Lab_team_color = "<none>";
  205. +
  206. // functions
  207. void labviewer_change_ship_lod(Tree *caller);
  208. void labviewer_change_ship(Tree *caller);
  209. @@ -705,7 +707,7 @@
  210. }
  211.  
  212. if (sip->uses_team_colors && !Teamcolor_override) {
  213. - gr_set_team_color(sip->default_team_name);
  214. + gr_set_team_color(Lab_team_color, "<none>", 0, 0);
  215. }
  216. }
  217.  
  218. @@ -1152,6 +1154,10 @@
  219. gr_string(gr_screen.clip_left + 10, gr_screen.clip_bottom - gr_get_font_height(), "FPS: ?", false);
  220. }
  221.  
  222. + //Print current Team Color setting, if any
  223. + if (Lab_team_color != "<none>")
  224. + gr_printf_no_resize(gr_screen.clip_left + 2, gr_screen.clip_bottom - (gr_get_font_height()) - 3, "Use T and Y to cycle through available Team Color settings. Current: %s", Lab_team_color);
  225. +
  226. //Print FXAA preset
  227. if (Cmdline_fxaa && !PostProcessing_override)
  228. gr_printf_no_resize(gr_screen.clip_left + 2, gr_screen.clip_bottom - (gr_get_font_height() * 2) - 3, "FXAA Preset: %i", Cmdline_fxaa_preset);
  229. @@ -1478,6 +1484,7 @@
  230. labviewer_variables_add(&y, "Name");
  231. labviewer_variables_add(&y, "Species");
  232. labviewer_variables_add(&y, "Type");
  233. + labviewer_variables_add(&y, "Default Team Color");
  234.  
  235. // physics
  236. VAR_ADD_HEADER("Physics");
  237. @@ -1607,6 +1614,7 @@
  238. VAR_SET_VALUE(sip->name);
  239. VAR_SET_VALUE_SAVE(sip->species, Species_info.size()-1);
  240. VAR_SET_VALUE_SAVE(sip->class_type, Ship_types.size()-1);
  241. + VAR_SET_VALUE(sip->default_team_name);
  242.  
  243. VAR_SET_VALUE_SAVE(sip->density, 0);
  244. VAR_SET_VALUE_SAVE(sip->damp, 0);
  245. @@ -2005,6 +2013,12 @@
  246.  
  247. labviewer_change_model(Ship_info[ship_index].pof_file, caller->GetSelectedItem()->GetData(), ship_index);
  248.  
  249. + if (Ship_info[ship_index].uses_team_colors) {
  250. + Lab_team_color = Ship_info[ship_index].default_team_name;
  251. + } else {
  252. + Lab_team_color = "<none>";
  253. + }
  254. +
  255. labviewer_update_desc_window();
  256. labviewer_update_flags_window();
  257. labviewer_update_variables_window();
  258. @@ -2280,6 +2294,8 @@
  259. Trackball_mode = 0;
  260. }
  261.  
  262. + //Due to switch scoping rules, this has to be declared here
  263. + SCP_map<SCP_string, team_color>::iterator color = Team_Colors.find(Lab_team_color);
  264. // handle any key presses
  265. switch (key) {
  266. // switch between the current insignia bitmap to render with
  267. @@ -2365,6 +2381,23 @@
  268. }
  269. break;
  270.  
  271. + case KEY_T:
  272. + if (color == Team_Colors.begin()) {
  273. + color = --Team_Colors.end();
  274. + Lab_team_color = color->first;
  275. + } else {
  276. + --color;
  277. + Lab_team_color = color->first;
  278. + }
  279. + break;
  280. +
  281. + case KEY_Y:
  282. + ++color;
  283. + if (color == Team_Colors.end())
  284. + color = Team_Colors.begin();
  285. + Lab_team_color = color->first;
  286. + break;
  287. +
  288. // bail...
  289. case KEY_ESC:
  290. labviewer_exit(NULL);
  291. Index: menuui/techmenu.cpp
  292. ===================================================================
  293. --- menuui/techmenu.cpp (revision 9274)
  294. +++ menuui/techmenu.cpp (working copy)
  295. @@ -466,7 +466,7 @@
  296. ship_info *sip = &Ship_info[Cur_entry_index];
  297.  
  298. if (sip->uses_team_colors) {
  299. - gr_set_team_color(sip->default_team_name);
  300. + gr_set_team_color(sip->default_team_name, "<none>", 0, 0);
  301. }
  302.  
  303. // get correct revolution rate
  304. Index: missionui/missionshipchoice.cpp
  305. ===================================================================
  306. --- missionui/missionshipchoice.cpp (revision 9274)
  307. +++ missionui/missionshipchoice.cpp (working copy)
  308. @@ -1534,7 +1534,7 @@
  309. }
  310.  
  311. if (sip->uses_team_colors) {
  312. - gr_set_team_color(sip->default_team_name);
  313. + gr_set_team_color(sip->default_team_name, "<none>", 0, 0);
  314. }
  315.  
  316. draw_model_rotating(ShipSelectModelNum,
  317. Index: parse/lua.cpp
  318. ===================================================================
  319. --- parse/lua.cpp (revision 9274)
  320. +++ parse/lua.cpp (working copy)
  321. @@ -6040,7 +6040,7 @@
  322. ship_info *sip = &Ship_info[idx];
  323.  
  324. if (sip->uses_team_colors) {
  325. - gr_set_team_color(sip->default_team_name);
  326. + gr_set_team_color(sip->default_team_name, "<none>", 0, 0);
  327. }
  328.  
  329. //Make sure model is loaded
  330. @@ -6112,7 +6112,7 @@
  331. ship_info *sip = &Ship_info[idx];
  332.  
  333. if (sip->uses_team_colors) {
  334. - gr_set_team_color(sip->default_team_name);
  335. + gr_set_team_color(sip->default_team_name, "<none>", 0, 0);
  336. }
  337.  
  338. //Make sure model is loaded
  339. Index: parse/sexp.cpp
  340. ===================================================================
  341. --- parse/sexp.cpp (revision 9274)
  342. +++ parse/sexp.cpp (working copy)
  343. @@ -95,6 +95,7 @@
  344. #include "asteroid/asteroid.h"
  345. #include "mod_table/mod_table.h"
  346. #include "ship/afterburner.h"
  347. +#include "globalincs/alphacolors.h"
  348.  
  349. #ifndef NDEBUG
  350. #include "hud/hudmessage.h"
  351. @@ -504,6 +505,7 @@
  352. { "add-to-collision-group", OP_ADD_TO_COLGROUP, 2, INT_MAX }, // The E
  353. { "remove-from-collision-group",OP_REMOVE_FROM_COLGROUP, 2, INT_MAX },
  354. { "get-collision-group", OP_GET_COLGROUP_ID, 1, 1 },
  355. + { "change-team-color", OP_CHANGE_TEAM_COLOR, 3, INT_MAX }, // The E
  356.  
  357. //Coordinate Manipulation Sub-Category
  358. { "set-object-position", OP_SET_OBJECT_POSITION, 4, 4 }, // WMC
  359. @@ -2683,6 +2685,16 @@
  360.  
  361. break;
  362.  
  363. + case OPF_TEAM_COLOR:
  364. + if (type2 != SEXP_ATOM_STRING) {
  365. + return SEXP_CHECK_TYPE_MISMATCH;
  366. + }
  367. +
  368. + if (Team_Colors.find(CTEXT(node)) == Team_Colors.end())
  369. + return SEXP_CHECK_INVALID_TEAM_COLOR;
  370. +
  371. + break;
  372. +
  373. case OPF_FONT:
  374. if (type2 != SEXP_ATOM_STRING) {
  375. return SEXP_CHECK_TYPE_MISMATCH;
  376. @@ -20719,6 +20731,28 @@
  377. }
  378. }
  379.  
  380. +void sexp_change_team_color(int n) {
  381. + SCP_string new_color = CTEXT(n);
  382. + n = CDR(n);
  383. + int fade_time = eval_num(n);
  384. +
  385. + while (n != -1) {
  386. + ship* shipp = sexp_get_ship_from_node(n);
  387. +
  388. + if (shipp != NULL) {
  389. + if (fade_time == 0) {
  390. + shipp->team_name = new_color;
  391. + } else {
  392. + shipp->secondary_team_name = new_color;
  393. + shipp->team_change_time = fade_time;
  394. + shipp->team_change_timestamp = Missiontime;
  395. + }
  396. + }
  397. +
  398. + CDR(n);
  399. + }
  400. +}
  401. +
  402. /**
  403. * Returns the subsystem type if the name of a subsystem is actually a generic type (e.g <all engines> or <all turrets>
  404. */
  405. @@ -23043,6 +23077,11 @@
  406. sexp_set_thrusters(node);
  407. break;
  408.  
  409. + case OP_CHANGE_TEAM_COLOR:
  410. + sexp_val = SEXP_TRUE;
  411. + sexp_change_team_color(node);
  412. + break;
  413. +
  414. default:
  415. Error(LOCATION, "Looking for SEXP operator, found '%s'.\n", CTEXT(cur_node));
  416. break;
  417. @@ -24000,6 +24039,7 @@
  418. case OP_SET_THRUSTERS:
  419. case OP_SET_PLAYER_THROTTLE_SPEED:
  420. case OP_DEBUG:
  421. + case OP_CHANGE_TEAM_COLOR:
  422. return OPR_NULL;
  423.  
  424. case OP_AI_CHASE:
  425. @@ -24914,6 +24954,14 @@
  426. case OP_SET_MISSION_MOOD:
  427. return OPF_MISSION_MOOD;
  428.  
  429. + case OP_CHANGE_TEAM_COLOR:
  430. + if (argnum == 0)
  431. + return OPF_TEAM_COLOR;
  432. + else if (argnum == 1)
  433. + return OPF_NUMBER;
  434. + else
  435. + return OPF_SHIP;
  436. +
  437. case OP_SELF_DESTRUCT:
  438. return OPF_SHIP;
  439.  
  440. @@ -27394,6 +27442,7 @@
  441. case OP_ADD_TO_COLGROUP:
  442. case OP_REMOVE_FROM_COLGROUP:
  443. case OP_GET_COLGROUP_ID:
  444. + case OP_CHANGE_TEAM_COLOR:
  445. return CHANGE_SUBCATEGORY_MODELS_AND_TEXTURES;
  446.  
  447.  
  448. @@ -31119,6 +31168,15 @@
  449. "\t1:\tThe player ship to set the throttle of.\r\n"
  450. "\t2:\tThe percentage of the player's maximum speed to set their throttle to.\r\n"
  451. "\t\tThis is capped to either 0 or 100 if outside the valid range."
  452. + },
  453. +
  454. + {OP_CHANGE_TEAM_COLOR, "change-team-color\r\n"
  455. + "\tChanges the team color setting for one or several ships.\r\n"
  456. + "\tThis sexp has no effect on ships that don't have team colors enabled for them.\r\n"
  457. + "\tTakes 3 or more arguments...\r\n"
  458. + "\t1:\tThe new team color name. Name must be defined in colors.tbl.\r\n"
  459. + "\t2:\tCrossfade time in milliseconds. During this time, colors will be mixed.\r\n"
  460. + "\t3:\tRest: List of ships this sexp will operate on."
  461. }
  462. };
  463.  
  464. Index: parse/sexp.h
  465. ===================================================================
  466. --- parse/sexp.h (revision 9274)
  467. +++ parse/sexp.h (working copy)
  468. @@ -107,6 +107,7 @@
  469. #define OPF_SHIP_EFFECT 80 // The E - per-ship effects, as defined in post-processing.tbl
  470. #define OPF_ANIMATION_TYPE 81 // Goober5000 - as defined in modelanim.h
  471. #define OPF_MISSION_MOOD 82 // Karajorma - Moods determine which builtin messages will be sent
  472. +#define OPF_TEAM_COLOR 83 // The E - Color settings as defined in Colors.tbl
  473.  
  474. // Operand return types
  475. #define OPR_NUMBER 1 // returns number
  476. @@ -702,7 +703,8 @@
  477. #define OP_DEBUG (0x0017 | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // Karajorma
  478. #define OP_SET_MISSION_MOOD (0x0018 | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // Karajorma
  479. #define OP_NAV_SELECT (0x0019 | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // Talon1024
  480. -#define OP_NAV_DESELECT (0x0020 | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // Talon1024
  481. +#define OP_NAV_DESELECT (0x001a | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // Talon1024
  482. +#define OP_CHANGE_TEAM_COLOR (0x001b | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // The E
  483.  
  484. // defined for AI goals
  485. #define OP_AI_CHASE (0x0000 | OP_CATEGORY_AI | OP_NONCAMPAIGN_FLAG)
  486. @@ -960,6 +962,7 @@
  487. #define SEXP_CHECK_INVALID_HUD_GAUGE -153
  488. #define SEXP_CHECK_INVALID_ANIMATION_TYPE -154
  489. #define SEXP_CHECK_INVALID_MISSION_MOOD -155
  490. +#define SEXP_CHECK_INVALID_TEAM_COLOR -156
  491.  
  492. #define TRAINING_CONTEXT_SPEED (1<<0)
  493. #define TRAINING_CONTEXT_FLY_PATH (1<<1)
  494. Index: ship/ship.cpp
  495. ===================================================================
  496. --- ship/ship.cpp (revision 9274)
  497. +++ ship/ship.cpp (working copy)
  498. @@ -5100,6 +5100,9 @@
  499.  
  500. // Team colors
  501. shipp->team_name.assign( sip->default_team_name);
  502. + shipp->secondary_team_name = "<none>";
  503. + shipp->team_change_time = 0;
  504. + shipp->team_change_timestamp = 0;
  505. }
  506.  
  507. /**
  508. @@ -6104,7 +6107,7 @@
  509. }
  510.  
  511. if (sip->uses_team_colors) {
  512. - gr_set_team_color(shipp->team_name);
  513. + gr_set_team_color(shipp->team_name, shipp->secondary_team_name, shipp->team_change_timestamp, shipp->team_change_time);
  514. }
  515.  
  516. if(sip->flags2 & SIF2_NO_LIGHTING)
  517. Index: ship/ship.h
  518. ===================================================================
  519. --- ship/ship.h (revision 9274)
  520. +++ ship/ship.h (working copy)
  521. @@ -776,6 +776,10 @@
  522. RadarVisibility radar_current_status; // Current radar status
  523.  
  524. SCP_string team_name;
  525. + SCP_string secondary_team_name; //If the change-team-color sexp is used, these fields control the fading behaviour
  526. + fix team_change_timestamp;
  527. + int team_change_time;
  528. +
  529. } ship;
  530.  
  531. struct ai_target_priority {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement