Correction de vector.empty() vers vector.clear().

This commit is contained in:
Marc-Eric Martel 2021-09-17 10:08:14 -04:00
parent 4deb7418c3
commit 13ccbff257
4 changed files with 8 additions and 6 deletions

View File

@ -2,7 +2,6 @@
#define BLOCKINFO_H__ #define BLOCKINFO_H__
#include "define.h" #include "define.h"
#include <iostream>
class BlockInfo { class BlockInfo {
public: public:

View File

@ -2,6 +2,7 @@
#define DEFINE_H__ #define DEFINE_H__
#include <string> #include <string>
#include <iostream>
#define CHUNK_SIZE_X 16 #define CHUNK_SIZE_X 16
#define CHUNK_SIZE_Y 128 #define CHUNK_SIZE_Y 128

View File

@ -5,7 +5,7 @@ int main() {
Chunk* testchunk = new Chunk(); Chunk* testchunk = new Chunk();
std::vector<BlockInfo*> testblock; std::vector<BlockInfo*> testblock;
std::cout << "-Test 1-------BlockInfo----------" << std::endl; std::cout << "-Test 1-------BlockInfo------------------" << std::endl;
testblock.push_back(new BlockInfo(BTYPE_AIR, "The air in the sky")); testblock.push_back(new BlockInfo(BTYPE_AIR, "The air in the sky"));
testblock.push_back(new BlockInfo(BTYPE_DIRT, "The dirt on the ground")); testblock.push_back(new BlockInfo(BTYPE_DIRT, "The dirt on the ground"));
@ -32,9 +32,11 @@ int main() {
testblock[index]->Show(); testblock[index]->Show();
std::cout << std::endl; std::cout << std::endl;
std::cout << "-Test 3--------Chunk Copy---------------" << std::endl; std::cout << "-Test 3--------Chunk Copy------------------" << std::endl;
Chunk testchunkcopy(*testchunk); Chunk testchunkcopy(*testchunk);
delete testchunk; delete testchunk;
testblock.push_back(new BlockInfo(testchunkcopy.GetBlock(0, 0, 0), "A block in a copied chunk")); testblock.push_back(new BlockInfo(testchunkcopy.GetBlock(0, 0, 0), "A block in a copied chunk"));
testblock.push_back(new BlockInfo(testchunkcopy.GetBlock(1, 0, 0), "A dirty block in a copied chunk")); testblock.push_back(new BlockInfo(testchunkcopy.GetBlock(1, 0, 0), "A dirty block in a copied chunk"));
testblock.push_back(new BlockInfo(testchunkcopy.GetBlock(1, 0, 0), "A grassy block in a copied chunk")); testblock.push_back(new BlockInfo(testchunkcopy.GetBlock(1, 0, 0), "A grassy block in a copied chunk"));
@ -43,11 +45,11 @@ int main() {
testblock[index]->Show(); testblock[index]->Show();
std::cout << std::endl; std::cout << std::endl;
std::cout << "-Test 3--------Chunk Reset/Remove Block-----------" << std::endl; std::cout << "-Test 3--------Chunk Reset/Remove Block-----" << std::endl;
testchunkcopy.Reset(BTYPE_GRASS); testchunkcopy.Reset(BTYPE_GRASS);
testchunkcopy.RemoveBlock(3, 0, 0); testchunkcopy.RemoveBlock(3, 0, 0);
testblock.empty(); testblock.clear();
for (int index = 0; index < 10; ++index) for (int index = 0; index < 10; ++index)
testblock.push_back(new BlockInfo(testchunkcopy.GetBlock(index, 0, 0), "A block in a reset chunk containing lots of grass")); testblock.push_back(new BlockInfo(testchunkcopy.GetBlock(index, 0, 0), "A block in a reset chunk containing lots of grass"));

View File

@ -2,7 +2,7 @@
#define MAIN_H__ #define MAIN_H__
#include <vector> #include <vector>
#include <iostream>
#include "define.h" #include "define.h"
#include "chunk.h" #include "chunk.h"
#include "blockinfo.h" #include "blockinfo.h"