feat: TU19 (Dec 2014) Features & Content (#155)
* try to resolve merge conflict
* feat: TU19 (Dec 2014) Features & Content (#32)
* December 2014 files
* Working release build
* Fix compilation issues
* Add sound to Windows64Media
* Add DLC content and force Tutorial DLC
* Revert "Add DLC content and force Tutorial DLC"
This reverts commit 97a4399472.
* Disable broken light packing
* Disable breakpoint during DLC texture map load
Allows DLC loading but the DLC textures are still broken
* Fix post build not working
* ...
* fix vs2022 build
* fix cmake build
---------
Co-authored-by: Loki <lokirautio@gmail.com>
This commit is contained in:
@@ -47,6 +47,17 @@ void SynchedEntityData::define(int id, short value)
|
||||
m_isEmpty = false;
|
||||
}
|
||||
|
||||
void SynchedEntityData::define(int id, float value)
|
||||
{
|
||||
MemSect(17);
|
||||
checkId(id);
|
||||
int type = TYPE_FLOAT;
|
||||
shared_ptr<DataItem> dataItem = shared_ptr<DataItem>( new DataItem(type, id, value) );
|
||||
itemsById[id] = dataItem;
|
||||
MemSect(0);
|
||||
m_isEmpty = false;
|
||||
}
|
||||
|
||||
void SynchedEntityData::define(int id, const wstring& value)
|
||||
{
|
||||
MemSect(17);
|
||||
@@ -100,8 +111,7 @@ int SynchedEntityData::getInteger(int id)
|
||||
|
||||
float SynchedEntityData::getFloat(int id)
|
||||
{
|
||||
assert(false); // 4J - not currently implemented
|
||||
return 0;
|
||||
return itemsById[id]->getValue_float();
|
||||
}
|
||||
|
||||
wstring SynchedEntityData::getString(int id)
|
||||
@@ -160,6 +170,19 @@ void SynchedEntityData::set(int id, short value)
|
||||
}
|
||||
}
|
||||
|
||||
void SynchedEntityData::set(int id, float value)
|
||||
{
|
||||
shared_ptr<DataItem> dataItem = itemsById[id];
|
||||
|
||||
// update the value if it has changed
|
||||
if (value != dataItem->getValue_float())
|
||||
{
|
||||
dataItem->setValue(value);
|
||||
dataItem->setDirty(true);
|
||||
m_isDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void SynchedEntityData::set(int id, const wstring& value)
|
||||
{
|
||||
shared_ptr<DataItem> dataItem = itemsById[id];
|
||||
@@ -188,7 +211,7 @@ void SynchedEntityData::set(int id, shared_ptr<ItemInstance> value)
|
||||
|
||||
void SynchedEntityData::markDirty(int id)
|
||||
{
|
||||
(*itemsById.find(id)).second->dirty = true;
|
||||
itemsById[id]->dirty = true;
|
||||
m_isDirty = true;
|
||||
}
|
||||
|
||||
@@ -221,11 +244,10 @@ vector<shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::packDirty()
|
||||
|
||||
if (m_isDirty)
|
||||
{
|
||||
AUTO_VAR(itEnd, itemsById.end());
|
||||
for ( AUTO_VAR(it, itemsById.begin()); it != itEnd; it++ )
|
||||
for( int i = 0; i <= MAX_ID_VALUE; i++ )
|
||||
{
|
||||
shared_ptr<DataItem> dataItem = (*it).second;
|
||||
if (dataItem->isDirty())
|
||||
shared_ptr<DataItem> dataItem = itemsById[i];
|
||||
if ((dataItem != NULL) && dataItem->isDirty())
|
||||
{
|
||||
dataItem->setDirty(false);
|
||||
|
||||
@@ -244,11 +266,13 @@ vector<shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::packDirty()
|
||||
|
||||
void SynchedEntityData::packAll(DataOutputStream *output) // throws IOException
|
||||
{
|
||||
AUTO_VAR(itEnd, itemsById.end());
|
||||
for (AUTO_VAR(it, itemsById.begin()); it != itEnd; it++ )
|
||||
for( int i = 0; i <= MAX_ID_VALUE; i++ )
|
||||
{
|
||||
shared_ptr<DataItem> dataItem = (*it).second;
|
||||
writeDataItem(output, dataItem);
|
||||
shared_ptr<DataItem> dataItem = itemsById[i];
|
||||
if(dataItem != NULL)
|
||||
{
|
||||
writeDataItem(output, dataItem);
|
||||
}
|
||||
}
|
||||
|
||||
// add an eof
|
||||
@@ -259,15 +283,17 @@ vector<shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::getAll()
|
||||
{
|
||||
vector<shared_ptr<DataItem> > *result = NULL;
|
||||
|
||||
AUTO_VAR(itEnd, itemsById.end());
|
||||
for (AUTO_VAR(it, itemsById.begin()); it != itEnd; it++ )
|
||||
for( int i = 0; i <= MAX_ID_VALUE; i++ )
|
||||
{
|
||||
if (result == NULL)
|
||||
shared_ptr<DataItem> dataItem = itemsById[i];
|
||||
if(dataItem != NULL)
|
||||
{
|
||||
result = new vector<shared_ptr<DataItem> >();
|
||||
if (result == NULL)
|
||||
{
|
||||
result = new vector<shared_ptr<DataItem> >();
|
||||
}
|
||||
result->push_back(dataItem);
|
||||
}
|
||||
shared_ptr<DataItem> dataItem = (*it).second;
|
||||
result->push_back(dataItem);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -292,6 +318,9 @@ void SynchedEntityData::writeDataItem(DataOutputStream *output, shared_ptr<DataI
|
||||
case TYPE_SHORT:
|
||||
output->writeShort( dataItem->getValue_short());
|
||||
break;
|
||||
case TYPE_FLOAT:
|
||||
output->writeFloat( dataItem->getValue_float());
|
||||
break;
|
||||
case TYPE_STRING:
|
||||
Packet::writeUtf(dataItem->getValue_wstring(), output);
|
||||
break;
|
||||
@@ -348,6 +377,13 @@ vector<shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::unpack(Data
|
||||
item = shared_ptr<DataItem>( new DataItem(itemType, itemId, dataRead) );
|
||||
}
|
||||
break;
|
||||
case TYPE_FLOAT:
|
||||
{
|
||||
float dataRead = input->readFloat();
|
||||
item = shared_ptr<DataItem>( new DataItem(itemType, itemId, dataRead) );
|
||||
|
||||
}
|
||||
break;
|
||||
case TYPE_STRING:
|
||||
item = shared_ptr<DataItem>( new DataItem(itemType, itemId, Packet::readUtf(input, MAX_STRING_DATA_LENGTH)) );
|
||||
break;
|
||||
@@ -382,25 +418,29 @@ void SynchedEntityData::assignValues(vector<shared_ptr<DataItem> > *items)
|
||||
for (AUTO_VAR(it, items->begin()); it != itEnd; it++)
|
||||
{
|
||||
shared_ptr<DataItem> item = *it;
|
||||
AUTO_VAR(itemFromId, itemsById.find(item->getId()));
|
||||
if (itemFromId != itemsById.end() )
|
||||
|
||||
shared_ptr<DataItem> itemFromId = itemsById[item->getId()];
|
||||
if( itemFromId != NULL )
|
||||
{
|
||||
switch(item->getType())
|
||||
{
|
||||
case TYPE_BYTE:
|
||||
itemFromId->second->setValue(item->getValue_byte());
|
||||
itemFromId->setValue(item->getValue_byte());
|
||||
break;
|
||||
case TYPE_SHORT:
|
||||
itemFromId->second->setValue(item->getValue_short());
|
||||
itemFromId->setValue(item->getValue_short());
|
||||
break;
|
||||
case TYPE_INT:
|
||||
itemFromId->second->setValue(item->getValue_int());
|
||||
itemFromId->setValue(item->getValue_int());
|
||||
break;
|
||||
case TYPE_FLOAT:
|
||||
itemFromId->setValue(item->getValue_float());
|
||||
break;
|
||||
case TYPE_STRING:
|
||||
itemFromId->second->setValue(item->getValue_wstring());
|
||||
itemFromId->setValue(item->getValue_wstring());
|
||||
break;
|
||||
case TYPE_ITEMINSTANCE:
|
||||
itemFromId->second->setValue(item->getValue_itemInstance());
|
||||
itemFromId->setValue(item->getValue_itemInstance());
|
||||
break;
|
||||
default:
|
||||
assert(false); // 4J - not implemented
|
||||
@@ -408,6 +448,9 @@ void SynchedEntityData::assignValues(vector<shared_ptr<DataItem> > *items)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// client-side dirty
|
||||
m_isDirty = true;
|
||||
}
|
||||
|
||||
bool SynchedEntityData::isEmpty()
|
||||
@@ -415,38 +458,47 @@ bool SynchedEntityData::isEmpty()
|
||||
return m_isEmpty;
|
||||
}
|
||||
|
||||
void SynchedEntityData::clearDirty()
|
||||
{
|
||||
m_isDirty = false;
|
||||
}
|
||||
|
||||
int SynchedEntityData::getSizeInBytes()
|
||||
{
|
||||
int size = 1;
|
||||
|
||||
AUTO_VAR(itEnd, itemsById.end());
|
||||
for (AUTO_VAR(it, itemsById.begin()); it != itEnd; it++ )
|
||||
|
||||
for( int i = 0; i <= MAX_ID_VALUE; i++ )
|
||||
{
|
||||
shared_ptr<DataItem> dataItem = (*it).second;
|
||||
|
||||
size += 1;
|
||||
|
||||
// write value
|
||||
switch (dataItem->getType())
|
||||
shared_ptr<DataItem> dataItem = itemsById[i];
|
||||
if(dataItem != NULL)
|
||||
{
|
||||
case TYPE_BYTE:
|
||||
size += 1;
|
||||
break;
|
||||
case TYPE_SHORT:
|
||||
size += 2;
|
||||
break;
|
||||
case TYPE_INT:
|
||||
size += 4;
|
||||
break;
|
||||
case TYPE_STRING:
|
||||
size += (int)dataItem->getValue_wstring().length() + 2; // Estimate, assuming all ascii chars
|
||||
break;
|
||||
case TYPE_ITEMINSTANCE:
|
||||
// short + byte + short
|
||||
size += 2 + 1 + 2; // Estimate, assuming all ascii chars
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
// write value
|
||||
switch (dataItem->getType())
|
||||
{
|
||||
case TYPE_BYTE:
|
||||
size += 1;
|
||||
break;
|
||||
case TYPE_SHORT:
|
||||
size += 2;
|
||||
break;
|
||||
case TYPE_INT:
|
||||
size += 4;
|
||||
break;
|
||||
case TYPE_FLOAT:
|
||||
size += 4;
|
||||
break;
|
||||
case TYPE_STRING:
|
||||
size += (int)dataItem->getValue_wstring().length() + 2; // Estimate, assuming all ascii chars
|
||||
break;
|
||||
case TYPE_ITEMINSTANCE:
|
||||
// short + byte + short
|
||||
size += 2 + 1 + 2; // Estimate, assuming all ascii chars
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return size;
|
||||
@@ -475,6 +527,12 @@ SynchedEntityData::DataItem::DataItem(int type, int id, short value) : type( typ
|
||||
this->dirty = true;
|
||||
}
|
||||
|
||||
SynchedEntityData::DataItem::DataItem(int type, int id, float value) : type( type ), id( id )
|
||||
{
|
||||
this->value_float = value;
|
||||
this->dirty = true;
|
||||
}
|
||||
|
||||
SynchedEntityData::DataItem::DataItem(int type, int id, const wstring& value) : type( type ), id( id )
|
||||
{
|
||||
this->value_wstring = value;
|
||||
@@ -507,6 +565,11 @@ void SynchedEntityData::DataItem::setValue(short value)
|
||||
this->value_short = value;
|
||||
}
|
||||
|
||||
void SynchedEntityData::DataItem::setValue(float value)
|
||||
{
|
||||
this->value_float = value;
|
||||
}
|
||||
|
||||
void SynchedEntityData::DataItem::setValue(const wstring& value)
|
||||
{
|
||||
this->value_wstring = value;
|
||||
@@ -527,6 +590,11 @@ short SynchedEntityData::DataItem::getValue_short()
|
||||
return value_short;
|
||||
}
|
||||
|
||||
float SynchedEntityData::DataItem::getValue_float()
|
||||
{
|
||||
return value_float;
|
||||
}
|
||||
|
||||
byte SynchedEntityData::DataItem::getValue_byte()
|
||||
{
|
||||
return value_byte;
|
||||
|
||||
Reference in New Issue
Block a user