Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dungeon generation #72

Open
wants to merge 9 commits into
base: terra
Choose a base branch
from
Open

dungeon generation #72

wants to merge 9 commits into from

Conversation

Tehsapper
Copy link

Generates a dungeon using supplied through stdin level info and upstairs positions (as arguments) from predefined and loaded dungeon pieces (all files in PIECES_DIR (./pieces/) ending in ".idp"). Outputs dungeon map into stdout.

Supports multi z-level dungeons, z-levels are separated by a single newline in both input/output.

Also includes very simple cave generator.

dungeon generation now uses predefined upstairs positions
l->zone_info.zones[zone-1].size--;

if (l->zone_info.zones[zone-1].size == 0) {
// Should also update zone info map values
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it kind of TODO?

/*
* Populates zone info by floodfill-testing empty spaces.
*/
void zone_test(level_t *l, int z) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The most disgusting variable name, ever given by developer. 1+l.

y = rand() % l->h;
if (AT(l, x, y, z) == '.') {
AT(l, x, y, z) = (down ? '>' : '<');
return (coords_t){ x, y, z };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it standard defined method to construct an initialized structure?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А точно есть в стандарте?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Есть, это compound literal, который появился в C99.
A postfix expression that consists of a parenthesized type name followed by a brace-enclosed list of initializers is a compound literal. It provides an unnamed object whose value is given by the initializer list.

}
}

char flag = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include stdbool...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Неа, true и false мы с тобой решили не использовать

* Returns an array of available dungeon generation parts.
*/
dg_parts_array_t load_gen_parts() {
dg_parts_array_t result = (dg_parts_array_t) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment about structures again

@zhmylove zhmylove added bug and removed bug labels May 22, 2018
@@ -0,0 +1,27 @@
CC=gcc
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Закомментить

@zhmylove
Copy link
Owner

Надо ещё добавить описание idp + то, как вызывать файл

ssize_t rtm_size = l->w * l->h * sizeof(int);

l->zone_info.count = 0;
l->zone_info.map = realloc(l->zone_info.map, rtm_size);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check

for (int k = 0; k < l->d; ++k) {
for (int j = 0; j < l->h; ++j ) {
for (int i = 0; i < l->w; ++i) {
if ((rand() % 100) > wall_rate) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/rand()/random()

y = rand() % l->h;
if (AT(l, x, y, z) == '.') {
AT(l, x, y, z) = (down ? '>' : '<');
return (coords_t){ x, y, z };
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А точно есть в стандарте?

* ret : 'pos' coordinates projected onto level
*/
coords_t sm2l(coords_t pos, int w, int h, int d, dir_t dir) {
(void)d;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут точно надо d?

* ret : resulting direction
*/
static dir_t _get_conn_dir(dg_gen_part_t *t, dir_t dir, int conn) {
int d;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Инициализировать

switch(p->dir) {
case NORTH:
// Does not fit into 80 chars sadly
AT(l, p->pos.x+i, p->pos.y+j, p->pos.z+k)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В математических кругах за такое бьют

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants