Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(ww3d2): draw the beach surf, which is the one strip left in the game
Olcay Seygan92c0c53781fc
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a002ebeda..1f70ad7d1 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -24,6 +24,7 @@ found and fixed — EA's own, not port damage.**- Briefing and cutscene subtitles hold long enough to read again.- The radar's under-attack pulse throbs instead of strobing, and no longer ends early.- The main menu surf rolls at its proper pace, not ten times too fast.+- And it is there at all again. The waves breaking on the main menu's beach had been worked out every frame and then drawn nowhere since v1.0.0, so the shore behind the menu was flat water.## The computer opponent builds a base nowdiff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cppindex b8f390126..0f094a36a 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp@@ -318,18 +318,39 @@ Int WaterTracksObj::render(DX8VertexBufferClass *vertexBuffer, Int batchStart)Real widthFrac;Real heightFrac;+ /* This is the one place in the tree that locks the Direct3D 9 buffer itself instead of going+ through VertexBufferClass's lock classes, and those classes are where the Direct3D 11 twin+ of a buffer is written. So under the Direct3D 11 backend the waves were sent to the card+ out of a twin nothing had ever filled: the draws were made, none were refused, and the surf+ was missing from the shell map's beach while Direct3D 9 still drew it. The lock keeps its+ own NOOVERWRITE/DISCARD flags - this is a dynamic buffer written every frame - so the twin+ is opened by hand here rather than by swapping in AppendLockClass, which locks with none. */+ const unsigned vertexSize = vertexBuffer->FVF_Info().Get_FVF_Size();+ const unsigned byteCount = m_x*m_y*vertexSize;+ unsigned byteOffset;+ unsigned lockFlags;+if (batchStart < (WATER_VB_PAGES*WATER_STRIP_X*WATER_STRIP_Y-m_x*m_y)){ //we have room in current VB, append new verts- if(vertexBuffer->Get_DX8_Vertex_Buffer()->Lock(batchStart*vertexBuffer->FVF_Info().Get_FVF_Size(),m_x*m_y*vertexBuffer->FVF_Info().Get_FVF_Size(),(void**)&vb,D3DLOCK_NOOVERWRITE) != D3D_OK)+ byteOffset = batchStart*vertexSize;+ lockFlags = D3DLOCK_NOOVERWRITE;+ if(vertexBuffer->Get_DX8_Vertex_Buffer()->Lock(byteOffset,byteCount,(void**)&vb,lockFlags) != D3D_OK)return batchStart;}else{ //ran out of room in last VB, request a substitute VB.- if(vertexBuffer->Get_DX8_Vertex_Buffer()->Lock(0,m_x*m_y*vertexBuffer->FVF_Info().Get_FVF_Size(),(void**)&vb,D3DLOCK_DISCARD) != D3D_OK)+ byteOffset = 0;+ lockFlags = D3DLOCK_DISCARD;+ if(vertexBuffer->Get_DX8_Vertex_Buffer()->Lock(byteOffset,byteCount,(void**)&vb,lockFlags) != D3D_OK)return batchStart;batchStart=0; //reset start of page to first vertex}+ DX11BufferLockClass dx11Lock;+ void *mirror = dx11Lock.Begin(vertexBuffer->Get_DX11_Twin(),vb,byteOffset,byteCount,lockFlags);+ if (mirror)+ vb = (VertexFormatXYZDUV1 *)mirror;+//Adjust wave position in a non-linear way so that it slows down as it hits the target. Using 1/4 sine wave//seems to work okay since it maxes out at 1.0 at our final position.//Real timeFrac=(Real)m_elapsedMs/(Real)m_totalMs;//sinf(0.5f*3.14159f*(Real)m_elapsedMs/(Real)m_totalMs);@@ -481,6 +502,7 @@ Int WaterTracksObj::render(DX8VertexBufferClass *vertexBuffer, Int batchStart)vb->v1=1.0f;vb++;+ dx11Lock.End();vertexBuffer->Get_DX8_Vertex_Buffer()->Unlock();Int idxCount=(m_y-1)*(m_x*2+2) - 2; //index countdiff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cppindex 1f8eb0c63..4f141d010 100644--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp@@ -2655,15 +2655,26 @@ void DX8Wrapper::Draw(polygon_count));}- // The same draw through the Direct3D 11 backend, into its own back buffer. Only- // triangle lists go: a strip or a fan would need its indices rebuilt, and the- // engine's own strips are already lists by the time they reach here.+ // The same draw through the Direct3D 11 backend, into its own back buffer. Lists+ // and strips both go: Direct3D 11 has a topology for each. A strip used to be+ // dropped here on the belief that nothing reached this point still striped, and+ // the beach surf did - so with Direct3D 11 presenting, the D3D9 draw above was+ // skipped and no draw replaced it, and the shell map's waves were drawn nowhere.+ // A fan is still dropped: Direct3D 11 has no fan topology, and its indices would+ // have to be rebuilt.if (primitive_type==D3DPT_TRIANGLELIST) {Direct3D11_Draw_Indexed_Triangles(polygon_count*3,start_index+render_state.iba_offset,render_state.index_base_offset+render_state.vba_offset);}+ else if (primitive_type==D3DPT_TRIANGLESTRIP) {+ // n indices make n-2 triangles, which is the count the caller passed.+ Direct3D11_Draw_Indexed_Strip(+ polygon_count+2,+ start_index+render_state.iba_offset,+ render_state.index_base_offset+render_state.vba_offset);+ }}break;case BUFFER_TYPE_SORTING: