entity_t and brush_t now converted to idEditorEntity and idEditorBrush

This commit is contained in:
Justin Marshall
2026-05-24 11:33:16 -07:00
parent d6d01e1faf
commit 3242531044
41 changed files with 1598 additions and 1540 deletions
+60 -60
View File
@@ -2548,23 +2548,23 @@ void CMainFrame::OnDestroy() {
}
while (entities.next != &entities) {
Entity_Free(entities.next);
idEditorEntity::Entity_Free(entities.next);
}
g_qeglobals.d_project_entity->epairs.Clear();
entity_t* pEntity = g_qeglobals.d_project_entity->next;
idEditorEntity* pEntity = g_qeglobals.d_project_entity->next;
while (pEntity != NULL && pEntity != g_qeglobals.d_project_entity) {
entity_t* pNextEntity = pEntity->next;
Entity_Free(pEntity);
idEditorEntity* pNextEntity = pEntity->next;
idEditorEntity::Entity_Free(pEntity);
pEntity = pNextEntity;
}
Texture_Cleanup();
if (world_entity) {
Entity_Free(world_entity);
idEditorEntity::Entity_Free(world_entity);
}
//
@@ -2572,7 +2572,7 @@ void CMainFrame::OnDestroy() {
// if (notexture) { // Timo // Surface properties plugin #ifdef _DEBUG if (
// !notexture->pData ) common->Printf("WARNING: found a qtexture_t* with no
// IPluginQTexture\n"); #endif if ( notexture->pData )
// GETPLUGINTEXDEF(notexture)->DecRef(); Mem_Free(notexture); }
// GETPLUGINTEXDEFnotexture->DecRef(); Mem_Free(notexture); }
// if (current_texture) free(current_texture);
//
@@ -2947,7 +2947,7 @@ void CMainFrame::OnFileSaveCopy() {
memset(&afn, 0, sizeof(OPENFILENAME));
CString strPath = ValueForKey(g_qeglobals.d_project_entity, "basepath");
CString strPath = g_qeglobals.d_project_entity->ValueForKey("basepath");
AddSlash(strPath);
strPath += "maps";
if (g_PrefsDlg.m_strMaps.GetLength() > 0) {
@@ -3690,10 +3690,10 @@ bool DoColor(int iIndex) {
extern void Select_SetKeyVal(const char* key, const char* val);
void CMainFrame::OnMiscSelectentitycolor() {
entity_t* ent = NULL;
idEditorEntity* ent = NULL;
if (QE_SingleBrush(true, true)) {
ent = selected_brushes.next->owner;
CString strColor = ValueForKey(ent, "_color");
CString strColor = ent->ValueForKey("_color");
if (strColor.GetLength() > 0) {
float fR, fG, fB;
int n = sscanf(strColor, "%f %f %f", &fR, &fG, &fB);
@@ -3722,7 +3722,7 @@ CString strReplaceKey;
CString strReplaceValue;
bool gbWholeStringMatchOnly = true;
bool gbSelectAllMatchingEnts = false;
brush_t* gpPrevEntBrushFound = NULL;
idEditorBrush* gpPrevEntBrushFound = NULL;
// all this because there's no ansi stristr(), sigh...
//
@@ -3748,11 +3748,11 @@ LPCSTR String_ToLower(LPCSTR psString)
}
bool FindNextBrush(brush_t* pPrevFoundBrush) // can be NULL for fresh search
bool FindNextBrush(idEditorBrush* pPrevFoundBrush) // can be NULL for fresh search
{
bool bFoundSomething = false;
entity_t* pLastFoundEnt;
brush_t* pLastFoundBrush;
idEditorEntity* pLastFoundEnt;
idEditorBrush* pLastFoundBrush;
CWaitCursor waitcursor;
@@ -3760,12 +3760,12 @@ bool FindNextBrush(brush_t* pPrevFoundBrush) // can be NULL for fresh search
// see whether to start search from prev_brush->next by checking if prev_brush is still in the active list...
//
brush_t* pStartBrush = active_brushes.next;
idEditorBrush* pStartBrush = active_brushes.next;
if (pPrevFoundBrush && !gbSelectAllMatchingEnts)
{
brush_t* pPrev = NULL;
for (brush_t* b = active_brushes.next; b != &active_brushes; b = b->next)
idEditorBrush* pPrev = NULL;
for (idEditorBrush* b = active_brushes.next; b != &active_brushes; b = b->next)
{
if (pPrev == pPrevFoundBrush && pPrevFoundBrush)
{
@@ -3782,8 +3782,8 @@ bool FindNextBrush(brush_t* pPrevFoundBrush) // can be NULL for fresh search
int iBrushesSelected = 0;
int iEntsScanned = 0;
brush_t* pNextBrush;
for (brush_t* b = pStartBrush; b != &active_brushes; b = pNextBrush)
idEditorBrush* pNextBrush;
for (idEditorBrush* b = pStartBrush; b != &active_brushes; b = pNextBrush)
{
// setup the <nextbrush> ptr before going any further (because selecting a brush down below moves it to a
// different link list), but we need to ensure that the next brush has a different ent-owner than the current
@@ -3805,7 +3805,7 @@ bool FindNextBrush(brush_t* pPrevFoundBrush) // can be NULL for fresh search
common->Printf("."); // cut down on printing
bool bMatch = false;
entity_t* ent = b->owner;
idEditorEntity* ent = b->owner;
if (ent && ent != world_entity) // needed!
{
@@ -3817,7 +3817,7 @@ bool FindNextBrush(brush_t* pPrevFoundBrush) // can be NULL for fresh search
//
if (!strFindKey.IsEmpty())
{
const char* psEntFoundValue = ValueForKey(ent, strFindKey);
const char* psEntFoundValue = ent->ValueForKey(strFindKey);
if (strlen(psEntFoundValue)
&&
@@ -3840,10 +3840,10 @@ bool FindNextBrush(brush_t* pPrevFoundBrush) // can be NULL for fresh search
{
// no FIND key specified, so just scan all of them...
//
int iNumEntKeys = GetNumKeys(ent);
int iNumEntKeys = ent->GetNumKeys();
for (int i = 0; i < iNumEntKeys; i++)
{
const char* psEntFoundValue = ValueForKey(ent, GetKeyString(ent, i));
const char* psEntFoundValue = ent->ValueForKey(ent->GetKeyString(i));
if (psEntFoundValue)
{
if ((strlen(psEntFoundValue) && strFindValue.IsEmpty()) // if blank <value> search specified then any found-value is ok
@@ -3941,19 +3941,19 @@ void CMainFrame::OnMiscFindOrReplaceEntity()
{
case ID_RET_REPLACE:
{
brush_t* next = NULL;
idEditorBrush* next = NULL;
int iOccurences = 0;
for (brush_t* b = active_brushes.next; b != &active_brushes; b = next)
for (idEditorBrush* b = active_brushes.next; b != &active_brushes; b = next)
{
next = b->next; // important to do this here, in case brush gets linked to a different list
entity_t* ent = b->owner;
idEditorEntity* ent = b->owner;
if (ent) // needed!
{
if (FilterBrush(b))
continue;
const char* psEntFoundValue = ValueForKey(ent, strFindKey);
const char* psEntFoundValue = ent->ValueForKey(strFindKey);
if (stricmp(strFindValue, psEntFoundValue) == 0 || // found this exact key/value
(strlen(psEntFoundValue) && strFindValue.IsEmpty()) // or any value for this key if blank value search specified
@@ -3961,13 +3961,13 @@ void CMainFrame::OnMiscFindOrReplaceEntity()
{
// found this search key/value, so delete it...
//
DeleteKey(ent, strFindKey);
ent->DeleteKey(strFindKey);
//
// and replace with the new key/value (if specified)...
//
if (!strReplaceKey.IsEmpty() && !strReplaceValue.IsEmpty())
{
SetKeyValue(ent, strReplaceKey, strReplaceValue);
ent->SetKeyValue(strReplaceKey, strReplaceValue);
}
iOccurences++;
}
@@ -4175,13 +4175,13 @@ void CMainFrame::OnBrushFlipx() {
Undo_AddBrushList(&selected_brushes);
Select_FlipAxis(0);
for (brush_t* b = selected_brushes.next; b != &selected_brushes; b = b->next) {
for (idEditorBrush* b = selected_brushes.next; b != &selected_brushes; b = b->next) {
if (b->owner->eclass->fixedsize) {
char buf[16];
float a = FloatForKey(b->owner, "angle");
float a = b->owner->FloatForKey("angle");
a = div((180 - a), 180).rem;
SetKeyValue(b->owner, "angle", itoa(a, buf, 10));
Brush_Build(b);
b->owner->SetKeyValue("angle", itoa(a, buf, 10));
b->Brush_Build();
}
}
Patch_ToggleInverted();
@@ -4198,9 +4198,9 @@ void CMainFrame::OnBrushFlipy() {
Undo_AddBrushList(&selected_brushes);
Select_FlipAxis(1);
for (brush_t* b = selected_brushes.next; b != &selected_brushes; b = b->next) {
for (idEditorBrush* b = selected_brushes.next; b != &selected_brushes; b = b->next) {
if (b->owner->eclass->fixedsize) {
float a = FloatForKey(b->owner, "angle");
float a = b->owner->FloatForKey("angle");
if (a == 0 || a == 180 || a == 360) {
continue;
}
@@ -4224,8 +4224,8 @@ void CMainFrame::OnBrushFlipy() {
a = (int)a % 360;
char buf[16];
SetKeyValue(b->owner, "angle", itoa(a, buf, 10));
Brush_Build(b);
b->owner->SetKeyValue("angle", itoa(a, buf, 10));
b->Brush_Build();
}
}
Patch_ToggleInverted();
@@ -4398,7 +4398,7 @@ void CMainFrame::OnSelectionCsgmerge() {
=======================================================================================================================
*/
void CMainFrame::OnSelectionDelete() {
brush_t* brush;
idEditorBrush* brush;
// if (ActiveXY()) ActiveXY()->UndoCopy();
Undo_Start("delete");
@@ -5972,8 +5972,8 @@ void CMainFrame::OnToolbarTexture() {
=======================================================================================================================
*/
void CMainFrame::OnSelectionPrint() {
for (brush_t* b = selected_brushes.next; b != &selected_brushes; b = b->next) {
Brush_Print(b);
for (idEditorBrush* b = selected_brushes.next; b != &selected_brushes; b = b->next) {
b->Brush_Print();
}
}
@@ -6751,13 +6751,13 @@ void CMainFrame::OnPatchTab() {
// check to see if the selected brush is part of a func group if it is, deselect
// everything and reselect the next brush in the group
//
brush_t* b = selected_brushes.next;
entity_t* e;
idEditorBrush* b = selected_brushes.next;
idEditorEntity* e;
if (b != &selected_brushes) {
if (idStr::Icmp(b->owner->eclass->name, "worldspawn") != 0) {
e = b->owner;
Select_Deselect();
brush_t* b2;
idEditorBrush* b2;
for (b2 = e->brushes.onext; b2 != &e->brushes; b2 = b2->onext) {
if (b == b2) {
b2 = b2->onext;
@@ -7587,7 +7587,7 @@ void CMainFrame::OnSelectionCombine()
return;
}
entity_t* e1 = g_qeglobals.d_select_order[0]->owner;
idEditorEntity* e1 = g_qeglobals.d_select_order[0]->owner;
if (e1 == world_entity) {
Sys_Status("First selection must not be world.", 0);
@@ -7603,47 +7603,47 @@ void CMainFrame::OnSelectionCombine()
// light_origin and light_rotation
e1->trackLightOrigin = true;
e1->brushes.onext->trackLightOrigin = true;
if (GetVectorForKey(e1, "origin", v)) {
SetKeyVec3(e1, "light_origin", v);
if (e1->GetVectorForKey("origin", v)) {
e1->SetKeyVec3("light_origin", v);
e1->lightOrigin = v;
}
if (!GetMatrixForKey(e1, "rotation", mat)) {
if (!e1->GetMatrixForKey("rotation", mat)) {
mat.Identity();
}
sprintf(str, "%g %g %g %g %g %g %g %g %g", mat[0][0], mat[0][1], mat[0][2], mat[1][0], mat[1][1], mat[1][2], mat[2][0], mat[2][1], mat[2][2]);
SetKeyValue(e1, "light_rotation", str, false);
e1->SetKeyValue("light_rotation", str, false);
e1->lightRotation = mat;
}
bool setModel = true;
for (brush_t* b = selected_brushes.next; b != &selected_brushes; b = b->next) {
for (idEditorBrush* b = selected_brushes.next; b != &selected_brushes; b = b->next) {
if (b->owner != e1) {
if (e1->eclass->nShowFlags & ECLASS_LIGHT) {
if (GetVectorForKey(b->owner, "origin", v)) {
if (b->owner->GetVectorForKey("origin", v)) {
e1->origin = b->owner->origin;
SetKeyVec3(e1, "origin", b->owner->origin);
e1->SetKeyVec3("origin", b->owner->origin);
}
if (GetMatrixForKey(b->owner, "rotation", mat)) {
if (b->owner->GetMatrixForKey("rotation", mat)) {
e1->rotation = b->owner->rotation;
mat = b->owner->rotation;
sprintf(str, "%g %g %g %g %g %g %g %g %g", mat[0][0], mat[0][1], mat[0][2], mat[1][0], mat[1][1], mat[1][2], mat[2][0], mat[2][1], mat[2][2]);
SetKeyValue(e1, "rotation", str, false);
e1->SetKeyValue("rotation", str, false);
}
if (b->modelHandle) {
SetKeyValue(e1, "model", ValueForKey(b->owner, "model"));
e1->SetKeyValue("model", b->owner->ValueForKey("model"));
setModel = false;
}
else {
b->entityModel = true;
}
}
Entity_UnlinkBrush(b);
Entity_LinkBrush(e1, b);
idEditorEntity::Entity_UnlinkBrush(b);
e1->Entity_LinkBrush(b);
}
}
if (setModel) {
SetKeyValue(e1, "model", ValueForKey(e1, "name"));
e1->SetKeyValue("model", e1->ValueForKey("name"));
}
Select_Deselect();
@@ -7655,7 +7655,7 @@ extern void Patch_Weld(patchMesh_t* p, patchMesh_t* p2);
void CMainFrame::OnPatchCombine() {
patchMesh_t* p, * p2;
p = p2 = NULL;
for (brush_t* b = selected_brushes.next; b != &selected_brushes; b = b->next) {
for (idEditorBrush* b = selected_brushes.next; b != &selected_brushes; b = b->next) {
if (b->pPatch) {
if (p == NULL) {
p = b->pPatch;
@@ -7894,8 +7894,8 @@ void CMainFrame::OnSelectAlltargets()
void CMainFrame::OnSelectCompleteEntity()
{
brush_t* b = NULL;
entity_t* e = NULL;
idEditorBrush* b = NULL;
idEditorEntity* e = NULL;
b = selected_brushes.next;
if (b == &selected_brushes)
@@ -7943,7 +7943,7 @@ void CMainFrame::OnGenerateMaterialsList()
Sys_BeginWait();
common->Printf("Generating list of active materials...\n");
for (brush_t* b = active_brushes.next; b != &active_brushes; b = b->next) {
for (idEditorBrush* b = active_brushes.next; b != &active_brushes; b = b->next) {
if (b->pPatch) {
mtrName = b->pPatch->d_texture->GetName();
if (!mtrList.Find(mtrName)) {