Skip to content

Commit

Permalink
Bugs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JENOT-ANT committed Aug 29, 2022
1 parent cbccbeb commit 9043f3e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
6 changes: 3 additions & 3 deletions ENIGMA-v0.1-alfa.0/enigma-app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void load_settings(Enigma* enigma, std::string settings_path)
} while (file_name[0] == COMMENT_CHAR);

file_name = DISKS_PATH + file_name + ".rtr";
notches = enigma->load_connections(file_name, connections);
notches = enigma->load_connections(file_name, connections, true);
enigma->add_disk(connections, notches.x, notches.y);
}

Expand Down Expand Up @@ -107,6 +107,6 @@ int main(int argc, char** argv)

load_settings(&enigma, SETTINGS_PATH);
cmd(argc, argv, &enigma);

return 0;
}
}
26 changes: 13 additions & 13 deletions ENIGMA-v0.1-alfa.0/libraries/enigma.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ namespace eng
int notch_second;

private: // private methods
void __correct_rotation__()
{
while (Disk::rotation >= Disk::size)
{
Disk::rotation -= Disk::size;
}
while (Disk::rotation < 0)
{
Disk::rotation += Disk::size;
}
}
// void __correct_rotation__()
// {
// while (Disk::rotation >= Disk::size)
// {
// Disk::rotation -= Disk::size;
// }
// while (Disk::rotation < 0)
// {
// Disk::rotation += Disk::size;
// }
// }

public: // public methods
// void load(std::string file_name)
Expand All @@ -87,14 +87,14 @@ namespace eng
{
// function used to rotate disk
Disk::rotation += rotation_tiks;
__correct_rotation__();
rotation = hq::normalize(Disk::rotation, Disk::size);
}

int forward(int index)
{
// pass signal through disk
index = hq::normalize(index + Disk::rotation, Disk::size);
return hq::normalize(Disk::connections[index] + Disk::size - Disk::rotation, Disk::size);
return hq::normalize(Disk::connections[index] - Disk::rotation, Disk::size);
}

void get_visual()
Expand Down
5 changes: 5 additions & 0 deletions ENIGMA-v0.1-alfa.0/libraries/headquarters.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ namespace hq

int normalize(int value, int max)
{
while (value < 0)
{
value += max;
}

return value % max;
}

Expand Down

0 comments on commit 9043f3e

Please sign in to comment.