| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/Main/entropy/EntropyRoom.cpp $ |
| 21 | * $Revision: 1.1.1.1 $ |
| 22 | * $Date: 2003/08/26 03:57:41 $ |
| 23 | * $Author: kevinb $ |
| 24 | * |
| 25 | * <insert description of file here> |
| 26 | * |
| 27 | * $Log: EntropyRoom.cpp,v $ |
| 28 | * Revision 1.1.1.1 2003/08/26 03:57:41 kevinb |
| 29 | * initial 1.5 import |
| 30 | * |
| 31 | * |
| 32 | * 15 10/21/99 9:28p Jeff |
| 33 | * B.A. Macintosh code merge |
| 34 | * |
| 35 | * 14 5/19/99 3:24p Jason |
| 36 | * fixed wrong ordering of InitObjectScripts and MultiSendObject |
| 37 | * |
| 38 | * 13 5/19/99 2:42a Jeff |
| 39 | * call correct NewUIGameWindow functions |
| 40 | * |
| 41 | * 12 5/12/99 11:28a Jeff |
| 42 | * added sourcesafe comment block |
| 43 | * |
| 44 | * $NoKeywords: $ |
| 45 | */ |
| 46 | |
| 47 | #include "gamedll_header.h" |
| 48 | #include <string.h> |
| 49 | #include <stdio.h> |
| 50 | #include <stdlib.h> |
| 51 | #include <ctype.h> |
| 52 | #include <math.h> |
| 53 | #include "idmfc.h" |
| 54 | #include "Entropystr.h" |
| 55 | #include "EntropyAux.h" |
| 56 | |
| 57 | extern IDMFC *DMFCBase; |
| 58 | |
| 59 | bool PaintRoomWithTexture(int text, int roomnum) { |
| 60 | if (ROOMNUM_OUTSIDE(roomnum)) { |
| 61 | Int3(); |
| 62 | return false; |
| 63 | } |
| 64 | |
| 65 | ASSERT((roomnum >= 0) && (roomnum <= DMFCBase->GetHighestRoomIndex())); |
| 66 | if ((roomnum < 0) || (roomnum > DMFCBase->GetHighestRoomIndex())) |
| 67 | return false; |
| 68 | |
| 69 | if (dRooms[roomnum].flags & RF_EXTERNAL) |
| 70 | return false; |
| 71 | |
| 72 | bool has_goalfaces = false; |
| 73 | int t; |
| 74 | for (t = 0; t < dRooms[roomnum].num_faces; t++) { |
| 75 | if (dRooms[roomnum].faces[t].flags & FF_GOALFACE) { |
| 76 | has_goalfaces = true; |
| 77 | break; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | texture *GameTextures = DMFCBase->GetGameTextures(); |
| 82 | dRooms[roomnum].room_change_flags |= RCF_TEXTURE; |
| 83 | |
| 84 | for (t = 0; t < dRooms[roomnum].num_faces; t++) { |
| 85 | texture *texp = &GameTextures[dRooms[roomnum].faces[t].tmap]; |
| 86 | if ((!(texp->flags & TF_ALPHA)) && texp->r < .01 && texp->g < .01 && texp->b < .01) { |
| 87 | if (!has_goalfaces || (dRooms[roomnum].faces[t].flags & FF_GOALFACE)) { |
| 88 | dRooms[roomnum].faces[t].tmap = text; |
| 89 | dRooms[roomnum].faces[t].flags |= FF_TEXTURE_CHANGED; |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | return true; |
| 94 | } |
| 95 | |
| 96 | int SpewObjectInRoom(int type, int id, int roomnum) { |
| 97 | if (DMFCBase->GetLocalRole() != LR_SERVER) |
| 98 | return -1; |
| 99 | |
| 100 | vector vpos; |
| 101 | int objnum; |
| 102 | |
| 103 | DLLComputeRoomCenter(&vpos, &dRooms[roomnum]); |
| 104 | objnum = DLLObjCreate(type, id, roomnum, &vpos, NULL, OBJECT_HANDLE_NONE); |
| 105 | if (objnum == -1) |
| 106 | return -1; |
| 107 | |
| 108 | object *obj = &dObjects[objnum]; |
| 109 | |
| 110 | ASSERT(obj->movement_type == MT_PHYSICS); |
| 111 | if (obj->movement_type != MT_PHYSICS) |
| 112 | return -1; |
| 113 | |
| 114 | // Set random velocity for powerups |
| 115 | obj->mtype.phys_info.velocity.x = ((float)rand() / static_cast<float>(RAND_MAX)) * 20.0; |
| 116 | obj->mtype.phys_info.velocity.z = ((float)rand() / static_cast<float>(RAND_MAX)) * 20.0; |
| 117 | obj->mtype.phys_info.velocity.y = ((float)rand() / static_cast<float>(RAND_MAX)) * 20.0; |
| 118 | |
| 119 | DLLMultiSendObject(obj, 0, true); |
| 120 | |
| 121 | DLLInitObjectScripts(obj, true); |
| 122 | |
| 123 | SendVirusCreate(obj); |
| 124 | |
| 125 | return objnum; |
| 126 | } |
| 127 | |
| 128 | void DoServerConfigureDialog(void) { |
| 129 | if (DMFCBase->GetLocalRole() != LR_SERVER) |
| 130 | return; |
| 131 | |
| 132 | char tempbuffer[20]; |
| 133 | bool exit_menu = false; |
| 134 | |
| 135 | void *start_game_text_off = DLLCreateNewUITextItem(TXT_STARTGAME, GR_WHITE, -1); |
| 136 | void *start_game_text_on = DLLCreateNewUITextItem(TXT_STARTGAME, GR_RED, -1); |
| 137 | void *virus_pk_text = DLLCreateNewUITextItem(TXT_VIRUSCREDIT, GR_WHITE, -1); |
| 138 | |
| 139 | void *main_wnd = DLLNewUIGameWindowCreate(0, 0, 256, 256, UIF_PROCESS_ALL | UIF_CENTER); |
| 140 | |
| 141 | int cury = 20; |
| 142 | void *virus_pk_edit = DLLEditCreate(main_wnd, 13, 40, cury, 80, 15, 0); |
| 143 | cury += 35; |
| 144 | void *start_game_hs = |
| 145 | DLLHotSpotCreate(main_wnd, UID_OK, K_ENTER, start_game_text_off, start_game_text_on, 40, cury, 130, 15, 0); |
| 146 | cury += 20; |
| 147 | |
| 148 | snprintf(tempbuffer, sizeof(tempbuffer), "%d", 2); |
| 149 | DLLEditSetText(virus_pk_edit, tempbuffer); |
| 150 | |
| 151 | DLLNewUIGameWindowOpen(main_wnd); |
| 152 | |
| 153 | while (!exit_menu) { |
| 154 | int res; |
| 155 | res = DLLPollUI(); |
| 156 | |
| 157 | if (res == -1) |
| 158 | continue; |
| 159 | |
| 160 | // handle all UI results. |
| 161 | switch (res) { |
| 162 | case NEWUIRES_FORCEQUIT: |
| 163 | exit_menu = true; |
| 164 | break; |
| 165 | case 13: // virus_pk edit |
| 166 | break; |
| 167 | case UID_OK: // start game |
| 168 | exit_menu = true; |
| 169 | DLLEditGetText(virus_pk_edit, tempbuffer, 20); |
| 170 | int newpk = atoi(tempbuffer); |
| 171 | DLLmprintf(0, "New Virus/Kill = %d\n", newpk); |
| 172 | break; |
| 173 | }; |
| 174 | } |
| 175 | DLLNewUIGameWindowClose(main_wnd); |
| 176 | DLLNewUIGameWindowDestroy(main_wnd); |
| 177 | |
| 178 | DLLRemoveUITextItem(start_game_text_on); |
| 179 | DLLRemoveUITextItem(start_game_text_off); |
| 180 | DLLRemoveUITextItem(virus_pk_text); |
| 181 | |
| 182 | DLLDeleteUIItem(main_wnd); |
| 183 | DLLDeleteUIItem(virus_pk_edit); |
| 184 | DLLDeleteUIItem(start_game_hs); |
| 185 | } |