Debug message changes and minor optimizations to DTSC library.
This commit is contained in:
parent
bca6097ae4
commit
8fde3f5851
1 changed files with 22 additions and 15 deletions
37
lib/dtsc.cpp
37
lib/dtsc.cpp
|
@ -540,7 +540,9 @@ DTSC::File & DTSC::File::operator =(const File & rhs){
|
||||||
F = 0;
|
F = 0;
|
||||||
}
|
}
|
||||||
endPos = rhs.endPos;
|
endPos = rhs.endPos;
|
||||||
myPack = rhs.myPack;
|
if (rhs.myPack){
|
||||||
|
myPack = rhs.myPack;
|
||||||
|
}
|
||||||
metaStorage = rhs.metaStorage;
|
metaStorage = rhs.metaStorage;
|
||||||
metadata = metaStorage;
|
metadata = metaStorage;
|
||||||
currtime = rhs.currtime;
|
currtime = rhs.currtime;
|
||||||
|
@ -793,19 +795,21 @@ void DTSC::File::seekNext(){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long packSize = ntohl(((uint32_t*)buffer)[0]);
|
long packSize = ntohl(((uint32_t*)buffer)[0]);
|
||||||
std::string strBuffer = "DTP2";
|
char * packBuffer = (char*)malloc(packSize+8);
|
||||||
if (version == 1){
|
if (version == 1){
|
||||||
strBuffer = "DTPD";
|
memcpy(packBuffer, "DTPD", 4);
|
||||||
|
}else{
|
||||||
|
memcpy(packBuffer, "DTP2", 4);
|
||||||
}
|
}
|
||||||
strBuffer.append(buffer, 4);
|
memcpy(packBuffer+4, buffer, 4);
|
||||||
strBuffer.resize(packSize + 8);
|
if (fread((void*)(packBuffer + 8), packSize, 1, F) != 1){
|
||||||
if (fread((void*)(strBuffer.c_str() + 8), packSize, 1, F) != 1){
|
|
||||||
DEBUG_MSG(DLVL_ERROR, "Could not read packet @ %d", (int)lastreadpos);
|
DEBUG_MSG(DLVL_ERROR, "Could not read packet @ %d", (int)lastreadpos);
|
||||||
myPack.null();
|
myPack.null();
|
||||||
|
free(packBuffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const char * tmp = strBuffer.data();
|
myPack.reInit(packBuffer, packSize+8);
|
||||||
myPack.reInit(tmp, strBuffer.size());
|
free(packBuffer);
|
||||||
if ( metadata.merged){
|
if ( metadata.merged){
|
||||||
int tempLoc = getBytePos();
|
int tempLoc = getBytePos();
|
||||||
char newHeader[20];
|
char newHeader[20];
|
||||||
|
@ -868,7 +872,7 @@ void DTSC::File::parseNext(){
|
||||||
readHeader(lastreadpos);
|
readHeader(lastreadpos);
|
||||||
std::string tmp = metaStorage.toNetPacked();
|
std::string tmp = metaStorage.toNetPacked();
|
||||||
myPack.reInit(tmp.data(), tmp.size());
|
myPack.reInit(tmp.data(), tmp.size());
|
||||||
DEBUG_MSG(DLVL_DEVEL,"Does this ever even happen?");
|
DEBUG_MSG(DLVL_DEVEL,"Read another header");
|
||||||
}else{
|
}else{
|
||||||
if (fread(buffer, 4, 1, F) != 1){
|
if (fread(buffer, 4, 1, F) != 1){
|
||||||
DEBUG_MSG(DLVL_ERROR, "Could not read header size @ %d", (int)lastreadpos);
|
DEBUG_MSG(DLVL_ERROR, "Could not read header size @ %d", (int)lastreadpos);
|
||||||
|
@ -906,18 +910,21 @@ void DTSC::File::parseNext(){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long packSize = ntohl(((uint32_t*)buffer)[0]);
|
long packSize = ntohl(((uint32_t*)buffer)[0]);
|
||||||
std::string strBuffer = "DTP2";
|
char * packBuffer = (char*)malloc(packSize+8);
|
||||||
if (version == 1){
|
if (version == 1){
|
||||||
strBuffer = "DTPD";
|
memcpy(packBuffer, "DTPD", 4);
|
||||||
|
}else{
|
||||||
|
memcpy(packBuffer, "DTP2", 4);
|
||||||
}
|
}
|
||||||
strBuffer.append(buffer, 4);
|
memcpy(packBuffer+4, buffer, 4);
|
||||||
strBuffer.resize(packSize + 8);
|
if (fread((void*)(packBuffer + 8), packSize, 1, F) != 1){
|
||||||
if (fread((void*)(strBuffer.c_str() + 8), packSize, 1, F) != 1){
|
|
||||||
DEBUG_MSG(DLVL_ERROR, "Could not read packet @ %d", (int)lastreadpos);
|
DEBUG_MSG(DLVL_ERROR, "Could not read packet @ %d", (int)lastreadpos);
|
||||||
myPack.null();
|
myPack.null();
|
||||||
|
free(packBuffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
myPack.reInit(strBuffer.data(), strBuffer.size());
|
myPack.reInit(packBuffer, packSize+8);
|
||||||
|
free(packBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the byte positon of the start of the last packet that was read.
|
/// Returns the byte positon of the start of the last packet that was read.
|
||||||
|
|
Loading…
Add table
Reference in a new issue