void ConvertCampaignSetting(CampaignSetting *dest, CampaignSettingOld *src) { int i; CFREE(dest->Title); CSTRDUP(dest->Title, src->title); CFREE(dest->Author); CSTRDUP(dest->Author, src->author); CFREE(dest->Description); CSTRDUP(dest->Description, src->description); for (i = 0; i < src->missionCount; i++) { Mission m; MissionInit(&m); ConvertMission(&m, &src->missions[i]); CArrayPushBack(&dest->Missions, &m); } CharacterStoreTerminate(&dest->characters); CharacterStoreInit(&dest->characters); for (i = 0; i < src->characterCount; i++) { Character *ch = CharacterStoreAddOther(&dest->characters); ConvertCharacter(ch, &src->characters[i]); CharacterSetLooks(ch, &ch->looks); } }
/*===========================================================================*/ extern "C" void d3dTextDrawString( char *pszString, int x, int y, PD3DFONTMETRICS pfntMetrics ) { int cIndex, nIndex, index; float cWidth = CX, cHeight = CY; /* Find the max width/height of a character and add the spacing so */ /* that we can use this value to calculate the x,y of the character.*/ cWidth = (cWidth * pfntMetrics->fntXScale) + pfntMetrics->fntXSpacing; cHeight = (cHeight * pfntMetrics->fntYScale) + pfntMetrics->fntYSpacing; /* Walk the string. This must be NULL terminated. */ for( cIndex = 0, nIndex = 0; *pszString; pszString++, cIndex = nIndex, x++ ) { /* Convert the character and get the index into the text vertex buffer. */ nIndex = ConvertCharacter( &pszString[0], cIndex, pfntMetrics ); if ( (nIndex - cIndex) > 2 ) { /* Modify the text vertex buffer based on the fntMetrics structure. */ for( index = cIndex; index < nIndex; index++ ) { /* Scale the character. */ TextVertices[index].sx *= pfntMetrics->fntXScale; TextVertices[index].sy *= pfntMetrics->fntYScale; /* Move the character. */ TextVertices[index].sx += (cWidth*x); TextVertices[index].sy += (cHeight*y); /* Set the color. */ TextVertices[index].color = pfntMetrics->dwColor; } } } if ( nIndex < 3 ) return; /* Set the states that slim things down. */ pfntMetrics->lpD3DDevice->SetRenderState( D3DRENDERSTATE_CULLMODE, D3DCULL_NONE ); pfntMetrics->lpD3DDevice->SetRenderState( D3DRENDERSTATE_FILLMODE, D3DFILL_SOLID ); pfntMetrics->lpD3DDevice->SetRenderState( D3DRENDERSTATE_ZENABLE, FALSE ); pfntMetrics->lpD3DDevice->SetRenderState( D3DRENDERSTATE_ZWRITEENABLE , FALSE ); pfntMetrics->lpD3DDevice->SetRenderState( D3DRENDERSTATE_ALPHATESTENABLE, FALSE ); pfntMetrics->lpD3DDevice->SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE, FALSE ); /* Blast them baby... */ pfntMetrics->lpD3DDevice->DrawPrimitive( D3DPT_TRIANGLELIST, D3DFVF_TLVERTEX, (LPVOID)&TextVertices[0], nIndex, (D3DDP_DONOTCLIP | D3DDP_DONOTLIGHT) ); }