I am the one that posted that comment.
For reference my comment was somewhere after the bounty was posted and before edit 5 (to the best of my recollection). This puts my comment before edit 7 where you removed a lot of code.
I will explain why I posted that comment and I hope you will understand my reasonings or at least see where I come from.
General rant
Out of all the reasons for which a questions is considered of low quality on this site I am personally most frustrated by posts that do not make the effort to trim down unnecessary code. Most kinds of bad questions I mostly ignore: questions of the like "please gimme the codes" are unsalvageable; question of simple basic matters will get answers from someone else or they will eventually find the answer in their text books; and so on.
(Debugging) Questions asking help about a real problem for which the OP is unlikely to find the answers in a book on their own interest me because I believe I can be of help. However when I see a big code dump with lots of lines of code that are completely irrelevant to the issue at hand frustrates me because I could help, but the OP didn't do what is in their power to enable me to help them. I don't have the time and the mental energy to swift thought previously unseen code to find that 1 issue in a sea of completely unrelated things that happen in the code: input read, full classes with full data members, constructors and methods, operator overloads, all sorts of unrelated functions, full bodies of functions etc.
I am willing to invest time in finding the problem if what I do in that time the OP couldn't have done it himself/herself. Removing unrelated code, translating id names, making a MRE is something that the OP could do. I know that most OPs don't do that not because of malice but because they don't know how and it frustrates me because it's something so simple that everyone could do that is a barrier for my investment in their problem.
For a concrete, clear example, a recent C++ question (deleted now, you need privilege to see it) was like this: the OP identified that the error is "no operator== found" for his class when he defined such an operator. The initial post contained 250 lines of code. I vote to close, post a comment about needed a MRE. After this the OP clearly tried to create a MRE. A few edits followed, each followed by my comment along the lines "still not minimal". This is what the OP finally managed to minimize to:
Tile.h:
#pragma once
#ifndef TILE_H
#define TILE_H
#include "GameObject.h"
#include "GL\glut.h"
#include <iostream>
class Tile : public GameObject
{
public:
Tile();
Tile(float, float, bool, bool);
int i;
int j;
Tile* parent;
bool operator==(const Tile& other) const;
bool operator!=(const Tile& other) const;
};
#endif
Tile.cpp:
Tile::Tile() : GameObject() { }
Tile::Tile(float x, float y, bool active, bool blocked)
{
this->x = x;
this->y = y;
this->active = active;
this->blocked = blocked;
parent = NULL;
}
bool Tile::operator==(const Tile& rhs) const
{
return this->i == rhs.i && this->j == rhs.j;
}
bool Tile::operator!=(const Tile& rhs) const
{
return this->i != rhs.i && this->j != rhs.j;
}
I have these two operators that are used to compare the two tiles with
the '==' operator and the '!=' operator.
Enemy.h:
#pragma once
#ifndef ENEMY_H
#define ENEMY_H
#include "GameObject.h"
#include "Tile.h"
#include "Math.h"
#include <vector>
class Enemy : public GameObject
{
Enemy();
Enemy(float, float, float, bool);
void MoveTowards(Tile, Tile*, std::vector<std::vector<Tile>>, int, int);
std::vector<Tile> *openList;
std::vector<Tile> *closedList;
std::vector<Tile>* AdjacentTiles(std::vector<std::vector<Tile>>, int, int);
};
#endif
Enemy.cpp:
Enemy::Enemy() { }
Enemy::Enemy(float x, float y, float radius, bool active)
{
this->x = x;
this->y = y;
this->radius = radius;
this->active = active;
}
void Enemy::MoveTowards(Tile currentTile, Tile* target, std::vector<std::vector<Tile>> worldTiles, int currentX, int currentY)
{
Tile *currentStep = &this->openList->at(0);
std::vector<Tile> *adjTiles = AdjacentTiles(worldTiles, currentStep->i, currentStep->j);
Tile* step = &adjTiles->at(0);
if (std::find(closedList->begin(), closedList->end(), step) != closedList->end())
{
//continue;
}
if (std::find(openList->begin(), openList->end(), step) != openList->end())
{
std::vector<Tile>::iterator it = std::find(this->openList->begin(), this->openList->end(), step);
int index = std::distance(this->openList->begin(), it);
step = &this->openList->at(index);
}
}
This is 105 LOC. Clearly an improvement from the original 250 LOC. Getting over the fact that it isn't compilable, the main issue is that is still contains a lot of distraction code that only adds to the mental strain when trying to analyze the code. I am sure the OP thought this is as minimal as he could get. But: is inheritance pertinent to the issue at hand? Are all the data members? Are the constructors? And so on.
Seeing how the OP is genuinely trying I went on, looked over his code, created a MRE and gave him the link to it. This is a proper MRE of the issue:
#include <algorithm>
#include <vector>
class Tile
{
public:
bool operator==(const Tile& other) const;
bool operator!=(const Tile& other) const;
};
class Enemy
{
std::vector<Tile>* closedList;
void MoveTowards()
{
Tile* step {};
std::find(closedList->begin(), closedList->end(), step);
}
};
If you stuck through this long post this here is the the main point of my answer: please look at the proper MRE and then look at the OP code. See how much easier is to analyze the MRE vs the OP's code. Me and all of us here have to look over a stranger's code without any previous knowledge of the problem and context of the code presented. See how easy is to look over a proper MRE and how much mental strain analyzing the other one involves. And now think about the original 250 LOC code. It's a previously unseen code that we would have to go through and for each and every think that happens we would need to see if it's relevant or not and if not how we can remove it without affecting the result (the error the OP is getting). All all of that is something that the OP, the one who asks for our volunteer help could have done and should have done.
Now back to your question
I hope that now you can see or even understand how when I came across your post what I saw were 250 LOC (coincidence, that is the same amount of LOCs as the original question in my example) with code that did all sorts of things:
- it stored encoded and decoded data
- it contained methods to emit and receive data
- it handled alerts from the server
- it handled sessions
- it stored all sorts of auth data (certificates, keys, stores)
- had all sorts of functions that were dealing with authorization and certifications
- creates certificates and private keys
- generates certificates and signs them
- reads a file from local storage
- creates a session
- connects to a server
- creates a certificate
- receives data
And on top of that we would need to install a library on our machine and start debugging your application. At that time there was no indication to me that you created this from a much larger multithreaded application. This was too much for me so I posted that comment immediately and I would have voted to close but the bounty prevented me.
With edit 7 you showed that your code was not minimal. You were able to reduce your code substantially to only 80 LOC (ignoring includes) code that visibly does less "things".
My "dump of your whole program" and "please debug my application" remarks were harsh and undeserving. I apologize for making them and for assuming you didn't do any substantial effort before posting. I also want to thank you for this meta posts as for me it serves as yet another reminder that for all those lazy questions there are also people genuinely doing their best. I should not have forgotten that.