Skip to content

Commit

Permalink
version 0.0.41, input lines that are too long will be truncated
Browse files Browse the repository at this point in the history
  • Loading branch information
EdHarry committed Jul 26, 2019
1 parent 69e41d8 commit e3ba143
Showing 1 changed file with 8 additions and 26 deletions.
34 changes: 8 additions & 26 deletions PretextMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#define PretextMap_Version "PretextMap Version 0.0.4"
#define PretextMap_Version "PretextMap Version 0.0.41"

#include "Header.h"
#include <math.h>
Expand Down Expand Up @@ -969,18 +969,19 @@ global_function
void
GrabStdIn()
{


line_buffer *buffer = 0;
u32 bufferPtr = 0;
s32 character;
while ((character = getchar()) != EOF)
{
while (!buffer) //TODO Semaphore for Queue has free buffer
if (!buffer) buffer = TakeLineBufferFromQueue_Wait(Line_Buffer_Queue);
buffer->line[bufferPtr++] = (u08)character;

if (bufferPtr == Line_Buffer_Size && character != 10)
{
buffer = TakeLineBufferFromQueue(Line_Buffer_Queue);
while ((character = getchar()) != 10) {}
buffer->line[bufferPtr-1] = (u08)character;
}
buffer->line[bufferPtr++] = (u08)character;

if (character == 10)
{
Expand Down Expand Up @@ -1028,7 +1029,7 @@ GrabStdIn()
case undet:
AddLineBufferToQueue(Line_Buffer_Queue, buffer);
break;

case sam:
case pairs:
ThreadPoolAddTask(Thread_Pool, ProcessLine, (void *)buffer);
Expand All @@ -1037,12 +1038,6 @@ GrabStdIn()
buffer = 0;
bufferPtr = 0;
}
else if (bufferPtr == Line_Buffer_Size)
{
buffer->line[bufferPtr-1] = '\0';
fprintf(stderr, "Error: line found larger than %d characters\n\n%s\n", Line_Buffer_Size, buffer->line);
break;
}
}
}

Expand Down Expand Up @@ -1698,17 +1693,13 @@ CreateDXTTextures()
{
*header++ = *ptr++;
}
//*((u64 *)header) = val64;
//header += 8;

u32 val32 = (u32)Number_of_Contigs;
ptr = (u08 *)&val32;
ForLoop(4)
{
*header++ = *ptr++;
}
//*((u32 *)header) = val32;
//header += 4;

ForLoop(Number_of_Contigs)
{
Expand All @@ -1721,31 +1712,22 @@ CreateDXTTextures()
{
*header++ = *ptr++;
}
//*((f32 *)header) = fracLength;
//header += 4;

ptr = (u08 *)name;
ForLoop2(64)
{
*header++ = *ptr++;
//*((u32 *)header) = name[index2];
//header += 4;
}
}

u08 val = Single_Texture_Resolution;
*header++ = val;
//*((u08 *)header) = val;
//header += 1;

val = (u08)nTextResolution;
*header++ = val;
//*((u08 *)header) = val;
//header += 1;

val = Number_of_LODs;
*header = val;
//*((u08 *)header) = val;

u32 nCommpressedBytes;
if (!(nCommpressedBytes = (u32)libdeflate_deflate_compress(compressor, (const void *)headerStart, nBytesHeader, (void *)compBuff, nBytesComp)))
Expand Down

0 comments on commit e3ba143

Please sign in to comment.