|
@@ -942,16 +942,18 @@ add_version(const Filename &name, Hash hash, Version version) {
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: DownloadDb::add_version
|
|
// Function: DownloadDb::add_version
|
|
|
// Access: Public
|
|
// Access: Public
|
|
|
-// Description:
|
|
|
|
|
|
|
+// Description: Note: version numbers start at 1
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
void DownloadDb::
|
|
void DownloadDb::
|
|
|
add_version(int name_code, Hash hash, Version version) {
|
|
add_version(int name_code, Hash hash, Version version) {
|
|
|
// Try to find this name_code in the map
|
|
// Try to find this name_code in the map
|
|
|
VersionMap::iterator i = _versions.find(name_code);
|
|
VersionMap::iterator i = _versions.find(name_code);
|
|
|
|
|
+ nassertv(version >= 1);
|
|
|
|
|
|
|
|
// If we did not find it, put a new vector_ulong at this name_code
|
|
// If we did not find it, put a new vector_ulong at this name_code
|
|
|
if (i == _versions.end()) {
|
|
if (i == _versions.end()) {
|
|
|
vector_ulong v;
|
|
vector_ulong v;
|
|
|
|
|
+ nassertv(version == 1);
|
|
|
v.push_back(hash);
|
|
v.push_back(hash);
|
|
|
_versions[name_code] = v;
|
|
_versions[name_code] = v;
|
|
|
} else {
|
|
} else {
|
|
@@ -961,8 +963,8 @@ add_version(int name_code, Hash hash, Version version) {
|
|
|
nassertv(version<=size);
|
|
nassertv(version<=size);
|
|
|
|
|
|
|
|
// If you are overwriting an old hash value, just insert the new value
|
|
// If you are overwriting an old hash value, just insert the new value
|
|
|
- if (version < size) {
|
|
|
|
|
- (*i).second[version] = hash;
|
|
|
|
|
|
|
+ if (version-1 < size) {
|
|
|
|
|
+ (*i).second[version-1] = hash;
|
|
|
} else {
|
|
} else {
|
|
|
// add this hash at the end of the vector
|
|
// add this hash at the end of the vector
|
|
|
(*i).second.push_back(hash);
|
|
(*i).second.push_back(hash);
|
|
@@ -985,7 +987,7 @@ get_version(const Filename &name, Hash hash) {
|
|
|
vector_ulong ulvec = (*vmi).second;
|
|
vector_ulong ulvec = (*vmi).second;
|
|
|
vector_ulong::iterator i = find(ulvec.begin(), ulvec.end(), hash);
|
|
vector_ulong::iterator i = find(ulvec.begin(), ulvec.end(), hash);
|
|
|
if (i != ulvec.end())
|
|
if (i != ulvec.end())
|
|
|
- return (i - ulvec.begin());
|
|
|
|
|
|
|
+ return (i - ulvec.begin() + 1);
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
|
|
|