Forums WoW Modding Support Archives TrinityCore Discord Archives [DiscordArchive] what about the case of (!cell.NoCreate()) being true ?

[DiscordArchive] what about the case of (!cell.NoCreate()) being true ?

[DiscordArchive] what about the case of (!cell.NoCreate()) being true ?

Pages (3): 1 2 3 Next
rektbyfaith
Administrator
0
03-22-2023, 08:36 PM
#1
Archived author: jackpoz • Posted: 2023-03-22T20:36:00.744000+00:00
Original source

what about the case of (!cell.NoCreate()) being true ?
rektbyfaith
03-22-2023, 08:36 PM #1

Archived author: jackpoz • Posted: 2023-03-22T20:36:00.744000+00:00
Original source

what about the case of (!cell.NoCreate()) being true ?

rektbyfaith
Administrator
0
03-22-2023, 08:36 PM
#2
Archived author: jackpoz • Posted: 2023-03-22T20:36:42.244000+00:00
Original source

because the body of that if has to handle both cases
rektbyfaith
03-22-2023, 08:36 PM #2

Archived author: jackpoz • Posted: 2023-03-22T20:36:42.244000+00:00
Original source

because the body of that if has to handle both cases

rektbyfaith
Administrator
0
03-22-2023, 08:37 PM
#3
Archived author: jackpoz • Posted: 2023-03-22T20:37:51.410000+00:00
Original source

the point of the current code calling EnsureGridLoaded(cell); is that there is 1 case where this is needed, which is when !cell.NoCreate() returns true and IsGridLoaded(GridCoord(x, y) returns false
rektbyfaith
03-22-2023, 08:37 PM #3

Archived author: jackpoz • Posted: 2023-03-22T20:37:51.410000+00:00
Original source

the point of the current code calling EnsureGridLoaded(cell); is that there is 1 case where this is needed, which is when !cell.NoCreate() returns true and IsGridLoaded(GridCoord(x, y) returns false

rektbyfaith
Administrator
0
03-22-2023, 08:38 PM
#4
Archived author: jackpoz • Posted: 2023-03-22T20:38:36.484000+00:00
Original source

ofc, the code could be "optimized" to avoid the EnsureGridLoaded(cell) call in the case !cell.NoCreate() is false and IsGridLoaded(GridCoord(x, y) is true
rektbyfaith
03-22-2023, 08:38 PM #4

Archived author: jackpoz • Posted: 2023-03-22T20:38:36.484000+00:00
Original source

ofc, the code could be "optimized" to avoid the EnsureGridLoaded(cell) call in the case !cell.NoCreate() is false and IsGridLoaded(GridCoord(x, y) is true

rektbyfaith
Administrator
0
03-22-2023, 08:41 PM
#5
Archived author: jackpoz • Posted: 2023-03-22T20:41:44.839000+00:00
Original source

https://gist.github.com/jackpoz/4e5b5b25...25acba4b99

```cpp
bool ensure = false, valid = false;
if (!cell.NoCreate())
{
ensure = true;
valid = true;
}
else if (IsGridLoaded(GridCoord(x, y))
{
ensure = false;
valid = true;
}

if (valid)
{
if (ensure)
EnsureGridLoaded(cell);
getNGrid(x, y)->VisitGrid(cell_x, cell_y, visitor);
}
```
rektbyfaith
03-22-2023, 08:41 PM #5

Archived author: jackpoz • Posted: 2023-03-22T20:41:44.839000+00:00
Original source

https://gist.github.com/jackpoz/4e5b5b25...25acba4b99

```cpp
bool ensure = false, valid = false;
if (!cell.NoCreate())
{
ensure = true;
valid = true;
}
else if (IsGridLoaded(GridCoord(x, y))
{
ensure = false;
valid = true;
}

if (valid)
{
if (ensure)
EnsureGridLoaded(cell);
getNGrid(x, y)->VisitGrid(cell_x, cell_y, visitor);
}
```

rektbyfaith
Administrator
0
03-22-2023, 08:42 PM
#6
Archived author: jackpoz • Posted: 2023-03-22T20:42:12.686000+00:00
Original source

now, not sure if the added complexity and unreadability is really that good
rektbyfaith
03-22-2023, 08:42 PM #6

Archived author: jackpoz • Posted: 2023-03-22T20:42:12.686000+00:00
Original source

now, not sure if the added complexity and unreadability is really that good

rektbyfaith
Administrator
0
03-22-2023, 08:42 PM
#7
Archived author: jackpoz • Posted: 2023-03-22T20:42:37.079000+00:00
Original source

but I take this is what you wanted ?
rektbyfaith
03-22-2023, 08:42 PM #7

Archived author: jackpoz • Posted: 2023-03-22T20:42:37.079000+00:00
Original source

but I take this is what you wanted ?

rektbyfaith
Administrator
0
03-22-2023, 08:44 PM
#8
Archived author: jackpoz • Posted: 2023-03-22T20:44:02.003000+00:00
Original source

well I guess it can be simplified:
```cpp
bool valid = false;
if (!cell.NoCreate())
{
EnsureGridLoaded(cell);
valid = true;
}
else if (IsGridLoaded(GridCoord(x, y))
{
valid = true;
}

if (valid)
getNGrid(x, y)->VisitGrid(cell_x, cell_y, visitor);
```
rektbyfaith
03-22-2023, 08:44 PM #8

Archived author: jackpoz • Posted: 2023-03-22T20:44:02.003000+00:00
Original source

well I guess it can be simplified:
```cpp
bool valid = false;
if (!cell.NoCreate())
{
EnsureGridLoaded(cell);
valid = true;
}
else if (IsGridLoaded(GridCoord(x, y))
{
valid = true;
}

if (valid)
getNGrid(x, y)->VisitGrid(cell_x, cell_y, visitor);
```

rektbyfaith
Administrator
0
03-22-2023, 08:44 PM
#9
Archived author: jackpoz • Posted: 2023-03-22T20:44:36.210000+00:00
Original source

now it doesn't look that bad anymore
rektbyfaith
03-22-2023, 08:44 PM #9

Archived author: jackpoz • Posted: 2023-03-22T20:44:36.210000+00:00
Original source

now it doesn't look that bad anymore

rektbyfaith
Administrator
0
03-22-2023, 08:55 PM
#10
Archived author: Gamemechanic • Posted: 2023-03-22T20:55:46.335000+00:00
Original source

```c++
if (!cell.NoCreate())
{
EnsureGridLoaded(cell);
getNGrid(x, y)->VisitGrid(cell_x, cell_y, visitor);
}
else if (IsGridLoaded(GridCoord(x, y))
{
getNGrid(x, y)->VisitGrid(cell_x, cell_y, visitor);
}```
Better or worse?
rektbyfaith
03-22-2023, 08:55 PM #10

Archived author: Gamemechanic • Posted: 2023-03-22T20:55:46.335000+00:00
Original source

```c++
if (!cell.NoCreate())
{
EnsureGridLoaded(cell);
getNGrid(x, y)->VisitGrid(cell_x, cell_y, visitor);
}
else if (IsGridLoaded(GridCoord(x, y))
{
getNGrid(x, y)->VisitGrid(cell_x, cell_y, visitor);
}```
Better or worse?

Pages (3): 1 2 3 Next
Recently Browsing
 
Recently Browsing